134

Is there a simple way of removing linebreaks in Notepad++?

For example:

This text has been splitted
in lines, and it's longer than
3200 words, so it would be great
to find and replace line breaks
like these.
3
  • 1
    Hmm, in VI it would be just typing 4J
    – Bernhard
    Dec 12 '12 at 9:11
  • If you are looking to compose something like a URL from putting the URI parameters on multiple lines, then this answer is a bit more helpful: stackoverflow.com/a/13990281/501113 Aug 19 '15 at 15:37
  • Do you expect spaces added: "This text has been splitted in lines, and it's longer than 3200 words..." or no spaces added: "This text has been splittedin lines, and it's longer than3200 words..." Each result requires a different technique.
    – ndemarco
    Nov 5 at 14:17
198
  1. Highlight the lines you want to join (or use Ctrl + A to select everything)
  2. Choose Edit → Line Operations → Join Lines from the menu or press Ctrl + J.

It will put in spaces automatically if necessary to prevent words from getting stuck together

6
  • Thanks but i has to be done one by one, is there a way to do this for the entire document?
    – Gabriel
    Dec 12 '12 at 9:28
  • 2
    I get it now, I selected the entire document and works exactly like I needed!
    – Gabriel
    Dec 12 '12 at 9:29
  • 7
    CTRL J is the shortcut
    – user640378
    Jan 15 '14 at 15:46
  • Tip: You might need to hit CTRL + J more than once. Do not use >View >Word wrap, to better see the linebreaks.
    – Avatar
    Nov 29 '16 at 11:54
  • 7
    how can I disable adding spaces? Mar 7 '17 at 21:17
49

CTRL+H

In Search Mode pick Extended

Find - \r\n Replace - leave it empty.

4
  • 5
    I believe it needs to be \r\n since this is for Windows.
    – James P
    Dec 12 '12 at 9:25
  • 3
    It should be \r\n and the replace field should contain one space character.
    – amiregelz
    Dec 12 '12 at 9:29
  • @JamesP, what is the difference? And why so in Windows?
    – user1993
    Jun 25 '17 at 8:16
  • 3
    @user1993: The Wikipedia article en.wikipedia.org/wiki/Newline has detailed information about how linebreaks work on different operating systems.
    – James P
    Jun 29 '17 at 8:53
2

For me, using Win 7, I had to use

\r

in the Find box and type in <space> in the Replace box so that there is a single space between the last word of the current line and the first word of the next line.

2
  • Did you mean \n
    – Prasanna
    Aug 28 '15 at 5:59
  • No, I mean \r. \n does nothing on my system.
    – Alan M
    Aug 31 '15 at 22:53

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