Line wrap in the current version
-
Hello,@I-neuw
Please follow these steps, To Line wrap in the current versionStep 1:- Open your Notepad++ and then click on the File menu in the menu bar and choose the open option to your document.
Step 2:- Click the View in the menu bar and choose the word wrap option into the list.
Step 3:- This will adjust the lines according to your Notepad++ window size.I hope this information will be useful to you.
Thank you. -
Hi, @i-neuw, @michael-vincent and All,
Have a look, too, at my updated post :
https://community.notepad-plus-plus.org/post/58912
Cheers,
guy038
-
Do you have super-powers enough here to ban the “Makwana Prahlad” bot-user?
-
Many users often noticed that your posts have always no relation with the real problem discussed !
So, although you can explain us why you proceed this way, in a reasonable time, I will be obliged to ban your account. Sorry !
BR
guy038
-
@Michael-Vincent said in Line wrap in the current version:
Regarding ruler in Notepad++
Using the ruler part of the ColumnTools plugin, I notice that it is “off”:
The ruler indicates the correct column number, but I expected it to be better vertially aligned with the caret position.
Does this happen for anyone else?
-
I will be taking an in-depth look at your solution to my “challenge”.
Thanks! -
@Alan-Kilborn said in Line wrap in the current version:
The ruler indicates the correct column number, but I expected it to be better vertially aligned with the caret position.
Does this happen for anyone else?It definitely happens if you have DirectWrite turned on:
Settings => Preferences… => MISC. => Use DirectWrite
It’s a known bug without a known solution :-)
Cheers.
-
@Alan-Kilborn said in Line wrap in the current version:
I will be taking an in-depth look at your solution to my “challenge”.
I had abandoned the previous regex and also the revised one which although supposed to fix a problem with non-indented lines may have actually caused another problem.
I then started (almost) afresh and finished up with a 4 step process that would ONLY work well in a macro. It entailed:
- coding empty (or blank filled) lines so they weren’t removed
- Breaking up at the first 80 char (or just before) and tagging the next (new) line with a continuation code so it could be prefixed with the “indentation”
- Replacing the continuation code with the indentation of the parent line (that it was cut from).
- Removal of the code to denote an empty (or blank filled) line.
And then repeating these 4 steps, hence the need for a macro to make it easy!
However in my research I stumbled across something I’d forgotten (as never used it) and it can be used to advantage. Hence my latest (and possibly the last) version is:
Find What:^(?=(\h++)?)(?=.{81,})(.{1,79})\h(.+)(\R|\z)
Replace With:\2\r\n\1\3\4
So the first capture group is actually within the positive lookahead. Then the search starts AGAIN from the first position in the line, checks for a “long” line and AGAIN restarts at the first position, then it finds the last “blank” before the 80 character position and cuts the remainder of the line off and prefixies it with the “indentation” (AKA 1st capture group). Note that a “TAB” character whilst occupying several spaces on the screen will ONLY occupy 1 position within the regex. So it can be possible that a line will exceed (slightly) the 80 character position if tabs are used within the document (at any position).
Unfortunately as when it writes the new “sub” line it has now gone past the start of that line and cannot process that line on this run, hence the need for multiple runs until the occurrences show
0
.Now in my research I realized that the
\h
used as a space/blank character ALSO includes the NBSP (non breaking space) character. So currently it could break at that point if one existed, but honestly I don’t see that as being the “end of the world” so I’m happy to live with it as is.So; as far as my testing shows; it will leave any current empty or blank filled line (as long as under 81 char). It works on both indented and NON-indented lines. My (limited) testing cannot show up any issues. Give it a whirl.
So have I managed a “single” regex solution? Well possibly although it must run multiple times.
Terry
-
Hi @Terry-R !
So I never got back to you on this. Sorry. :-(
Having more time over the end-of-year “slowdown”, I took a deeper dive into some things on my “to do” list. This was one of them; also on the list are/were finishing scripts for replace-all-in-any-type-of-selection and replace-all-with-incrementing-count. Perhaps other threads will get updates soon as well! But I digress…
So I started testing your regex.
The “having to run it multiple times” seemed like a deal-breaker, at first, but then while I’m in the middle of playing around with it, N++ 7.9.2 is released with a new feature that seems to help:What I can do is select the text I want to “reformat” and then run your replacement regex op with the In selection option turned on. This, with the indicated change in 7.9.2, keeps the (post-replacement) selection correct for another run(s) of the replacement. N++ 7.9.1 and earlier does not allow this.
So what I’m thinking is that I can make a macro of this, and edit it to duplicate the replacement action an arbitrarily large (e.g. 10 ?) number of times to cover most of my typical reformatting needs.
More testing to come, but it appears promising.
In hindsight, I’m glad I waited this long to give it a try.
Thank you for your efforts. -
@Terry-R said in Line wrap in the current version:
^(?=(\h++)?)
Terry, one more question for you:
What were the conditions for which you found it necessary to use the possessive (++
) qualifier here?
I’m confused as to why the greedy (+
) qualifier would not have worked as well – although I’ll admit I just thought about it, I didn’t try things with it. -
@Alan-Kilborn said in Line wrap in the current version:
What were the conditions for which you found it necessary to use the possessive (++) qualifier here?
Looking back at it now there wouldn’t have been any reason to do so. Possibly I had brought that forward from a previous version but as it’s within the lookahead, there will never be a reason for the regex engine to give up any of those characters.
It would seem that it’s safe to just leave it as greedy (
+
).Cheers
Terry -
Things are going good with this…
One thing I noted is that sometimes one has a need to reformat lines that are actually shorter than the desired amount, instead of longer.
Running your regular expression is obviously designed to handle longer-than-desired lines (which is OK, since that was the original spec).One would think that you could just use Notepad++'s Join Lines feature first, to give your expression something long enough to work on. However, I noticed when doing that, for any indented lines, when the lines are joined, the leading indent spaces on lines subsequent to the first – how many ever there are – are retained. :-(
So I came up with an In Selection Replace All action that will do the joining of lines and reduce any leading indents down to one space:
find:
(\R\x20+)|(\R\z)|(\R)
repl:(?1\x20)(?3\x20)
-
@Alan-Kilborn said in Line wrap in the current version:
So I came up with an In Selection Replace All action that will do the joining of lines and reduce any leading indents down to one space
I didn’t explicitly say it, but hopefully it was understood that I would use that on groups of lines that start out indented at the same level, NOT on a whole big set of lines that has various sections indented to differing levels. That wouldn’t work (well, it would work but wouldn’t provide a desired outcome).
-