How do I remove linebreaks in Notepad++?

115

40

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.

Gabriel

Posted 2012-12-12T09:06:23.047

Reputation: 2 271

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: http://stackoverflow.com/a/13990281/501113

– chaotic3quilibrium – 2015-08-19T15:37:37.593

1Hmm, in VI it would be just typing 4J – Bernhard – 2012-12-12T09:11:06.630

Answers

157

  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

James P

Posted 2012-12-12T09:06:23.047

Reputation: 9 542

Tip: You might need to hit CTRL + J more than once. Do not use >View >Word wrap, to better see the linebreaks. – Kai Noack – 2016-11-29T11:54:41.567

4how can I disable adding spaces? – Keith Tyler – 2017-03-07T21:17:21.113

I think you would have to use the Find/Replace method given in the other answers, you need to leave the Replace text completely empy – James P – 2017-03-08T08:08:41.753

Thanks but i has to be done one by one, is there a way to do this for the entire document? – Gabriel – 2012-12-12T09:28:00.883

2I get it now, I selected the entire document and works exactly like I needed! – Gabriel – 2012-12-12T09:29:35.860

6CTRL J is the shortcut – user640378 – 2014-01-15T15:46:56.707

40

CTRL+H

In Search Mode pick Extended

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

Ofiris

Posted 2012-12-12T09:06:23.047

Reputation: 1 623

@JamesP, what is the difference? And why so in Windows? – user1993 – 2017-06-25T08:16:18.763

2

@user1993: The Wikipedia article https://en.wikipedia.org/wiki/Newline has detailed information about how linebreaks work on different operating systems.

– James P – 2017-06-29T08:53:36.850

4I believe it needs to be \r\n since this is for Windows. – James P – 2012-12-12T09:25:48.630

2It should be \r\n and the replace field should contain one space character. – amiregelz – 2012-12-12T09:29:30.410

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.

Alan M

Posted 2012-12-12T09:06:23.047

Reputation: 163

Did you mean \n – Prasanna – 2015-08-28T05:59:23.427

No, I mean \r. \n does nothing on my system. – Alan M – 2015-08-31T22:53:36.837