How do I wrap lines in Notepad++ after N symbols?

74

14

I would like to have my lines in plain text in Notepad++ wrapped (soft wrapping for display, not insertion of line ends) after a reasonable amount of symbols (like 65 or 80). Is it possible?

The only option I came across is wrapping at window width, which gives ridiculous results provided one uses high resolution, non-gigantic fonts and maximized windows.

xxzoid

Posted 2011-12-06T15:47:47.527

Reputation: 1 257

6Click View menu --> toggle Word wrap. – Eric Leschinski – 2014-11-26T15:40:16.383

7He's looking for a way to wrap to a certain number of characters, not just at window width. View -> Word Wrap only wraps to window width. – keyofnight – 2015-08-03T18:47:29.380

Answers

53

According to this source you can somewhat mimic such behavior at least since Notepad++ 5.7

  1. Select “View” from menu bar.
  2. From the dropdown menu that appears click on “Word wrap” option.
  3. either open another editor in other view and move the divider (or alternatively resize editor window) until text wraps at the desired number of characters

Jörg

Posted 2011-12-06T15:47:47.527

Reputation: 707

10That doesn't wrap text to a custom number of characters... – Jerry – 2014-04-18T13:01:27.700

2@Jerry That's right, to mimic such behavior you have to open another editor in other view and move the divider until wrapping is to your liking. – Jörg – 2014-04-22T09:21:34.603

29

First Install the TextFX plugin from the plugin menu. Note: it available only for 32-bit version of Notepad++.

You can split long lines with this menu command: TextFX -> TextFX Edit -> ReWrap Text to (Clipboard or 72) width which means if you want to rewrap to something other than 72 characters you should type and copy that number (without any spaces) to clipboard and then use this option.

It works in my Notepad++ v6.9 and you have to select the lines you want to split.

Vladislav

Posted 2011-12-06T15:47:47.527

Reputation: 391

8

This regex replace worked well enough for me:

Find what:

^(.{60,80})\s

Replace with:

\1\n

Replace All

If some lines couldn't be split to between 60 and 80 characters, those lines will be left unmodified. Hopefully they will be few enough to deal with manually.

Brilliand

Posted 2011-12-06T15:47:47.527

Reputation: 193

This works pretty well, although if you have very long tokens (e.g. urls) it won't work on those lines. – Keith Tyler – 2017-10-16T23:36:43.320

2Obvious in retrospect, but make sure you don't have ". matches newline" checked. Otherwise existing line breaks are part of the 80 characters found, then you will have lines that end up shorter than intended. – Stephen Klancher – 2018-04-15T17:50:53.373

This is the best answer presented, IMHO. While answers involving adding plug-ins are helpful, they don;t describe how to do it with the software as provided. Some of us cannot install things. This solution does not "automatically" wrap at a specified column (equivalent to number of symbols, so long as we agree that white space is symbols), but it automates it enough for my purposes.

Also, the comment by Stephen Klancher is of great value.

Finally, I see that this question has not had an answer selected. I nominate this answer -- it solved my problem. – None – 2018-06-09T06:50:52.443

Unless I am seriously mistaken, this solution inserts newlines (\n) into the text. The OP explicitly did state that he does not want this. Excerpt from the original question: "[...] (soft wrapping for display, not insertion of line ends) [...]". – Binarus – 2020-02-04T07:20:02.790

@Binarus That's correct. Funny, I hadn't even noticed until now that the OP didn't want newlines. But it doesn't matter; the OP may not have wanted newlines inserted, but I think there are a lot of people coming here through Google who do (because the title doesn't make the distinction). – Brilliand – 2020-02-04T21:31:13.027

6

No, it is not possible is current versions of Notepad++. There is a feature request for it, but it has not been implemented yet.

As close as you can get (which isn't very):

  1. Create a vertical line at a specified number of columns Preferences -> Editing -> Vertical Split but N++ will not wrap to it.
  2. A very gimmicky option is to split the display using View -> Clone but obviously does not really solve the issue.
  3. Hard coding is possible with TextFX plugins, or using Ctrl + I shortcuts

For more details you can see the N++ wiki on manging line lengths.

peanut_butter

Posted 2011-12-06T15:47:47.527

Reputation: 1 722

It is possible with plugins check https://superuser.com/a/817874/487118

– AmirHossein – 2017-07-26T11:32:17.473

1

There is a solution/workaround for this; Sourceforge Notepad++ Forum - Enable/disable word wrap by language? Involving the use of NPPExec and a python script, adjusting a given language's word wrap property. Not ideal but it may work for you.

There is also a feature request on IdeaTorrent for this problem.

wonea

Posted 2011-12-06T15:47:47.527

Reputation: 1 737