Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to search/replace newlines

    Help wanted · · · – – – · · ·
    2
    7
    11049
    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 Puckett
      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 Frank 1 Reply Last reply Reply Quote 0
      • Claudia Frank
        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 Puckett
          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 Frank 1 Reply Last reply Reply Quote 0
          • Claudia Frank
            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 Puckett
              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 Frank 1 Reply Last reply Reply Quote 0
              • Claudia Frank
                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 Puckett
                  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
                  Copyright © 2014 NodeBB Forums | Contributors