• Login
Community
  • Login

How to search/replace newlines

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
7 Posts 2 Posters 12.2k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C
    Chuck Puckett
    last edited by Jan 21, 2016, 10:24 PM

    I’m trying to replace multiple newlines in a file with a single newline, but having no luck.
    I tried searching for \n\n (with various options checked and unchecked), but fail to find any. I can find SINGLE newlines, but not two in a row, at least with this syntax.
    Could not find any help in the app.
    Any suggestions?

    C 1 Reply Last reply Jan 21, 2016, 10:27 PM Reply Quote 0
    • C
      Claudia Frank @Chuck Puckett
      last edited by Jan 21, 2016, 10:27 PM

      Hello Chuck-Puckett,

      keep in mind that windows uses \r\n as eol.
      Where as unix uses \n and mac \r.

      Maybe \r\n does the trick.

      Cheers
      Claudia

      1 Reply Last reply Reply Quote 0
      • C
        Chuck Puckett
        last edited by Jan 21, 2016, 10:51 PM

        I find \r\n, and thanks for that. But my replacement attempts go astray.
        What I’m trying to do is make something like this

        line 1

        line 2

        line 3

        into this:

        line 1
        line 2
        line 3

        I can get of newlines in a selection by replacing \r\n with a space. But I need to eliminate empty lines.

        More ideas?

        C 1 Reply Last reply Jan 21, 2016, 10:55 PM Reply Quote 0
        • C
          Claudia Frank @Chuck Puckett
          last edited by Jan 21, 2016, 10:55 PM

          Assuming the empty line is really empty I would use regular expression and

          find what   : ^$
          replace with:
          

          If you press the show all characters, is the line really empty?

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 0
          • C
            Chuck Puckett
            last edited by Jan 21, 2016, 11:16 PM

            Didn’t think about that. Notepad++ is so much more than Notepad :)
            It shows CR LF at thened of each line, CR LF in the blank lines.
            Is that equivalent to ^$?

            C 1 Reply Last reply Jan 21, 2016, 11:19 PM Reply Quote 0
            • C
              Claudia Frank @Chuck Puckett
              last edited by Claudia Frank Jan 21, 2016, 11:22 PM Jan 21, 2016, 11:19 PM

              Not really
              ^ marks the beginnig of a line
              and $ the end.
              ^$ means you are looking for lines which basically have nothing then EOL chars.
              Therefore replacing wouldn’t hurt other lines.

              Cheers
              Claudia

              Btw. One thing i always forget Edit->Line operation->remove empty lines

              1 Reply Last reply Reply Quote 0
              • C
                Chuck Puckett
                last edited by Jan 22, 2016, 12:24 AM

                Well, really, that last sentence was all I needed. :)
                Tnx!
                Guess it’s time I spent some time roaming around Notepad++ menus instead of thinking I’m using my grandad’s Notepad. :)

                1 Reply Last reply Reply Quote 0
                5 out of 7
                • First post
                  5/7
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors