How can a paragraph be reformatted in Notepad++?

24

9

How can I reformat a paragraph in Notepad++?

In UltraEdit I can select one or more long lines and reformat the paragraph to the set right margin (e.g. 60 or 80) by menu command Format/Reformat Paragraph, keyboard shortcut Ctrl + T. Note that it is hard formatting (inserting line ends), not how the document is displayed in the editor.

How can the equivalent be done in Notepad++?

Peter Mortensen

Posted 2010-01-24T19:02:56.103

Reputation: 10 992

Answers

18

It's sort of weird.

If you just want to wrap a paragraph at 72 characters you can just go to TextFX>TextFX Edit>ReWrap Text to (Clipboard or 72) width. Which will re-wrap your selected text to 72 characters.

If you want a 61 or 87 character wrap however, you need to copy the text "61" into your clipboard and then do the same thing (TextFX>TextFX Edit>ReWrap Text to (Clipboardor 72) width).

I'm sure Don HO would be interested in a patch for some TextFX Reformat Paragraph stuff, if you were so inclined.

Tyler

Posted 2010-01-24T19:02:56.103

Reputation: 4 203

1The clipboard thing is impractical as I am constantly using this feature, but the hardcoded value of 72 is probably acceptable. I will see if I can figure out how to attach a keyboard shortcut to the ReWrap command. – Peter Mortensen – 2010-01-24T23:55:20.003

Note that TextFX is not supported with 64-bit Notepad++. You can, however, keep a 32-bit and a 64-bit version of the program on your machine, and use the 32-bit version to run TextFX. Alternatively, if all you want to do is wrap lines, you can use the methods described in the other answers to this question, which work in the 64-bit version (at least in v7.5.4). – Alan – 2018-01-22T17:00:22.163

1Good-However. It will 'join' my lines together. It does not respect the new-lines I have manually inserted. – Felipe Alvarez – 2010-09-17T11:12:06.910

This doesn't preserve indentation, either – endolith – 2012-10-16T15:44:51.103

33

This can now be done (at least in v5.9.8) via the combination of some commands in the Edit menu. Edit > Line Operations > Split Lines will insert a hard wrap at the width of the window. The hotkey for this is Ctrl-I. Edit > Line Operations > Join Line will join lines and has a hotkey of Ctrl-J.

So for a paragraph on one line, if you want to wrap at 60 or 80, resize your window to 60 or 80 characters wide, select the line you would like to hard-wrap, and hit Ctrl-I.

Alternatively, if your paragraph was already formatted to a different width, select all the lines of the paragraph and hit Ctrl-J. Then follow the aforementioned steps and you'll have a newly formatted paragraph!

Michael Herold

Posted 2010-01-24T19:02:56.103

Reputation: 461

I think if you have a vertical edge enabled it wraps to that instead of the window size, as CodeLurker points out in his answer and as I experienced today (npp version=6.9.2). – Samuel – 2016-08-31T23:25:03.063

This doesn't preserve indentation of the first line, though. – endolith – 2012-10-16T15:45:17.627

4+1 for solution not involving additional plugins – Benny – 2012-12-28T03:51:02.843

1this doesn't preserve functional formatting either, eg textbf{beup} isn't considered as one word :( – Gunther Struyf – 2013-05-20T10:03:10.027

5

To put it all together, go to Settings > Preferences > Editing > Show Vertical Edge, and check it. If you don't actually want to see the "Vertical Edge," i.e. the wrapping line, select "Background Mode". Next, set your column width by clicking the number after Number of Columns.

Select your text, then hit Ctrl-J (i.e. Join Lines), Ctrl-I (Split Lines).

Edit: If Show Vertical Edge isn't checked, it wraps to the window instead.

CodeLurker

Posted 2010-01-24T19:02:56.103

Reputation: 176

0

Try Settings > Preferences > Editing > Show Vertical Edge

Martzipan

Posted 2010-01-24T19:02:56.103

Reputation: 1

0

Pro-tip if you're looking to wrap by comma/delimiter (based on the answer by Michael Herold above):

  • Use a macro to separate each symbol into a new line
  • e.g. Home, Ctrl+Right, Right, Enter, for comma-delimited entries
  • then Play back the macro N times
  • Select all
  • Size your window to the desired column width (Settings -> Preferences -> Editing -> Number of Columns, and on the same page Show Verical Edge)
  • Ctrl+J
  • DON'T CHANGE THE WINDOW SIZE
  • Select all
  • Ctrl+I

This trick will size by e.g. comma delimiter, whereas just using Ctrl+I will not, very useful if you have e.g. 1000+ such lines.

smaudet

Posted 2010-01-24T19:02:56.103

Reputation: 161