2

I would like to know if is a method to remove linebreaks in Notepad++ aside from

 select  and   cntrl + J 

that is already explain here

How to remove linebreaks in Notepad++?

the Problem is that im trying to do a DML throught Excel to Notepad++ and when i copy the cells (from excel to notepad ++) it look like like this

-- Input 

 Insert into  table (
     line 1,
     line 2,
     line 3 ..

 Insert into  table (
     line 1,
     line 2,
     line 3..


--Output 

   Insert into table ( line1, line2,..)
   Insert into table (line1,line2,...)
    ...

so select each insert and make cntr + J is of course a solution but I wonder if there is any better that dont make me doing Manual 1 to 1 (because the DML in Excel could have like 1000 rows)

  • huh, ctrl with capital j, will add a new line, not remove one and can you show some the output you want. And anyhow, surely you can look up how to remove new lines, it's just search for either \r or \r\n and replace with nothing. That has to have been asked before, and if all you're asking is how to remove all new lines then there's no need for any text example, as people know what new lines are. – barlop Jan 28 '16 at 10:23
  • and you can do e.g. searching for some text up to a new line. into[^\r\n]* – barlop Jan 28 '16 at 10:28
  • hi @barlop !! thanks for answer , if you do that find and replace \n then u have a very Long row, but just one. is the same like cntrl A + cntrl + J . – Enrique Benito Casado Jan 28 '16 at 10:42
  • the find section has the new line \r or \r\n or \n, the replace section should not have \r or \r\n or \n. In Windows generally one uses \r\n in linux \n. So you might want \r\n – barlop Jan 28 '16 at 11:19
  • @barlop find and replace doesnt work for me with "\r\n" just "\n" do you know why ?? i dont know if ist important but is at the end of the Notepad++ "UNIX in UTF-8 . it does matter? – Enrique Benito Casado Jan 28 '16 at 11:49
1

Your example is very specific and my not be accurate, but assuming it is ...

<space>Insert

or

<many spaces><some value>

You want to leave the single space lines alone, remove \n from the rest.

  • Menu "Search" > "Replace" (or Ctrl + H)

  • Set "Find what" to "\n[space][space]*"

  • Set "Replace with" "[nothing]"
  • Enable "Regular expression"
  • Click "Replace All"

Where [space] is an actual space. That takes any pattern with at line break, followed by least 2 spaces and flattens it out. Then fix the blank space on the first line.

For reference: How to use regular expressions in Notepad++

  • hi @lan W , thanks for your answer , your solutions is Valid , Worked , thanks !! – Enrique Benito Casado Feb 5 '16 at 9:14
0

How do I removed linebreaks in Notepad++?

I can't give you a perfect solution as your example input is incomplete, but you can start with the following.

  • Menu "Search" > "Replace" (or Ctrl + H)

  • Set "Find what" to \r\n +

  • Set "Replace with" to nothing

  • Enable "Regular expression"

  • Click "Replace All"

    Image

  • Set "Find what" to \r\n\r\n

  • Set "Replace with" to \r\n

  • Enable "Regular expression"

  • Click "Replace All"

    enter image description here

Before:

Insert into  table (
     line 1,
     line 2,
     line 3 ..

Insert into  table (
     line 1,
     line 2,
     line 3..

After:

Insert into  table ( line 1, line 2, line 3 ..
Insert into  table ( line 1, line 2, line 3..

Further reading

  • Thanks @davidPostill for your answer it look like pretty good, but i dont know why i dont why cntrl + h and find \r\n or \r doesnt give me any resul "0 ocurrence was replaced" do you know why ? I dont know if is important but is in "UNIX" "UTF-8" under the Notepad ++ – Enrique Benito Casado Jan 28 '16 at 11:44
  • \r\n is <cr><lf> (newline) on Windows. See \r\n , \r , \n what is the difference between them? – DavidPostill Jan 28 '16 at 11:48
  • hi @DavidPostill thanks for the link and i Change may Notepad++(to Windows) just to try, "\r\n" work in the same way that did in Unix "\n" so take all the text and Change it in a single line but the step 2) •Set "Find what" to \r\n\r\n •Set "Replace with" to \r\n doesnt have any reault ... do you have a clue why ? – Enrique Benito Casado Jan 28 '16 at 12:13
  • No. It works with your test data. Maybe you have extra spaces? Try \r\n +\r\n (In step 1 " +" matches spaces) – DavidPostill Jan 28 '16 at 12:15
  • If you have Unix <eol>s then use \n instead of \r\n – DavidPostill Jan 28 '16 at 12:36

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.