15

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.

  • Are you working with text that needs to be literally exactly X columns wide? Or do you want a maximum of X columns? – Wolfkin Jun 13 '16 at 16:59
20
  • 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.
  • Note that there is no Find and replace way to reverse these changes. You will have to use Undo if you want to reverse it.
  • Note that we are changing the text to fix the line length. If you just want to see long lines in the window in the view menu select "Word Wrap".
  • ^.{4} means starting from the beginning of the line find the first 4 characters.
  • $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.)
3

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.

2

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.

  1. Use EOL functions (Split Line)
  2. Regular Expressions
  3. TextFx Plugin

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.

0

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.

Navegation: Text Editor>>>Tools>>>Text Splitter enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.