Is there a way in notepad++, to split one line text, to text with given maximum number of characters in one line? I found only undefined line split in lines operations.
4 Answers
- Press CTRL+H to bring up Search and replace.
- In the find what box enter:
^.{4}
(Where 4 may be modified to any number representing the number of characters you want per line.) - In the replace field enter
$0\r\n
- In search mode select "Regular expression"
- To wrap all lines click "Replace All"
Notes:
- Before using "Replace all" you may want to click "Find next" and "Replace" a few times to verify that your search is working the way you intend it to.
- There is no Find and replace way to reverse these changes. You will have to use Undo if you want to reverse it.
- We are changing the text to fix the line length. If you just wish for your text to wrap to the next line at the end of the window, turn on "Word Wrap"
^.{4}
means find the first four characters from the beginning of the line in Regex.$0\r\n
means take the information found and replace it with that same information followed by a carriage return and a line feed. (Note that in *nix systems carriage returns and line feeds are dealt with differently.)
Yes, this is possible.
If you do a search/replace and use Regex as option, the following regex will allow you to split a line in two.
^(.{4})(.+)
Replace the number 4 with the amount of chars you want to find. Replace with $1 and $2 to find the first and second string. Replacing it with $1-$2 will place a - in between both strings.
You see to be asking about how to wrap text. Depending on your use you may want a soft wrap or a hard wrap.
soft wrap
This means that the text will split at X columns wide but when you copy and paste it to say MS Word it will expand again to fill the page. In otherwords it's just a visual compression
hard wrap
This means N++ will actually add newlines (Carriage Returns, enter whatever you want to call them*). I presume this is what you want.
There's a number of ways to do it.
Off about 80 seconds of testing I'd recommend the TextFx Plugin. It depends how firm you want that split to be.
* - though yes I understand that CF/LF are different.
You can use CodVerter Online Text Editor that has a simple tool
exactly for this assignment.
Text can be splitted by a number of characters or by a delimiter.