Author Topic: Goto next line when max line length reached  (Read 5192 times)

leosard

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Goto next line when max line length reached
« on: August 08, 2016, 08:13:20 am »
Hi,

I'd like my editor to go to next line (newline) when the maximal line length that I defined is reached.
I am able to configure max line length in: Tools->Options->Languages->Application Languages->C/C++->General. Under "truncation" I can select Line length. I set it to 120.

Now when I reach this length then I'd expect the cursor to go to new line automatically. But it doesn't, I keep typing chars but nothing happens.
Please assist.

Tim Kemp

  • Senior Community Member
  • Posts: 541
  • Hero Points: 92
Re: Goto next line when max line length reached
« Reply #1 on: August 08, 2016, 10:59:33 am »
What you are looking for is Word Wrap, not truncation.

leosard

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Re: Goto next line when max line length reached
« Reply #2 on: August 08, 2016, 11:53:06 am »
Thanks for the answer!

I just tried word wrap and it looks good except the fact that it affects existing lines:
As I start typing a new line, once I type a single letter then automatically this letter is moved to the next (existing) line, changing existing code.

What I want is simple. Once (and only) I reach my line limit (say 120 chars) then I'd like a new line to begin without affecting existing lines.
It sounds something trivial but no matter how long I play with SE settings I still can't achieve this behavior.

My Word Wrap configuration is attached.
« Last Edit: August 08, 2016, 12:23:13 pm by leosard »

Tim Kemp

  • Senior Community Member
  • Posts: 541
  • Hero Points: 92
Re: Goto next line when max line length reached
« Reply #3 on: August 08, 2016, 12:25:31 pm »
To prevent the word wrapping from extending beyond the paragraph you are currently typing in, you need to have blank lines between lines.

Here is a block of text with long lines:


I inserted a space on the second line so that line wrapped:


As you can see, it only wrapped the current line.

Here are my settings:

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6467
  • Hero Points: 504
Re: Goto next line when max line length reached
« Reply #4 on: August 08, 2016, 12:49:47 pm »
If you don't want full word wrap, try checking partial word wrap. I don't remember exactly what it does off the top of my head but it might do what you want.

leosard

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Re: Goto next line when max line length reached
« Reply #5 on: August 08, 2016, 01:28:24 pm »
Thanks for the answers!

Is there a way that word wrap will only effect current line? My original code is without blank lines. I don't want to expand existing code to have blank lines between each line.

All I want is that new lines that I write or old lines that I modify will be wrapped, without affecting other lines.

It sounds like the most basic usage of word wrap.

Thanks,
Leon

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6467
  • Hero Points: 504
Re: Goto next line when max line length reached
« Reply #6 on: August 08, 2016, 01:32:03 pm »
We will have to look into that. Definitely would be easy to implement.

leosard

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Re: Goto next line when max line length reached
« Reply #7 on: August 08, 2016, 01:38:15 pm »
Thanks!

The current word wrap mechanism messes the code and makes it even less readable (which is the opposite of what word wrap should do) since it combines unrelated lines.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6467
  • Hero Points: 504
Re: Goto next line when max line length reached
« Reply #8 on: August 09, 2016, 03:39:50 am »
There's a problem with implementing this. You've stated what you want to happen when you're typing at the end of the line. That's the trivial obvious case.

What should happen if the line becomes too line and you're typing in the middle of the line. If there are say 5 words after the cursor, you will end up creating 5 lines (one for each word) if you make sure you never insert into the next line. The alternative is not to word wrap until the cursor reaches the right margin no matter what. That's sounds pretty bad too but maybe that's what you expect?

leosard

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Re: Goto next line when max line length reached
« Reply #9 on: August 09, 2016, 07:12:33 am »
The alternative is not to word wrap until the cursor reaches the right margin no matter what. That's sounds pretty bad too but maybe that's what you expect?

That's the expectation, the margin is the limit, so only when this limit is reached a new line should begin. That's the whole point of limiting the line to a certain length in my opinion.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6467
  • Hero Points: 504
Re: Goto next line when max line length reached
« Reply #10 on: August 09, 2016, 12:57:48 pm »
Even if the cursor is in the middle of the line with half the line past the right margin?

jporkkahtc

  • Senior Community Member
  • Posts: 2619
  • Hero Points: 210
  • Text
Re: Goto next line when max line length reached
« Reply #11 on: August 09, 2016, 07:51:46 pm »
Leosard: Is there another editor that you use that has the behavior you want?


As Clark asked, when you insert text in the middle of the line, making the line too long even though the cursor remains within the margin limit?
What if you insert a word - causing a wrap - then you backspace to erase it -- would you expect the line to be unwrapped?

There isn't room in a plain text file for meta data or such to track where the editor has wrapped text vs. the user.
So after wrapping the last word on the line to a new one, it won't know that it should wrap the next word into that line.