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.
    • Chuck PuckettC
      Chuck Puckett
      last edited by

      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?

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • Claudia FrankC
        Claudia Frank @Chuck Puckett
        last edited by

        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
        • Chuck PuckettC
          Chuck Puckett
          last edited by

          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?

          Claudia FrankC 1 Reply Last reply Reply Quote 0
          • Claudia FrankC
            Claudia Frank @Chuck Puckett
            last edited by

            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
            • Chuck PuckettC
              Chuck Puckett
              last edited by

              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 ^$?

              Claudia FrankC 1 Reply Last reply Reply Quote 0
              • Claudia FrankC
                Claudia Frank @Chuck Puckett
                last edited by Claudia Frank

                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
                • Chuck PuckettC
                  Chuck Puckett
                  last edited by

                  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
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors