Community
    • Login

    Ctrl-J (join lines) replaces LF with space

    Scheduled Pinned Locked Moved General Discussion
    8 Posts 3 Posters 191 Views 2 Watching
    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.
    • DougK.AZD Offline
      DougK.AZ
      last edited by

      I have a private key in pem format that is split into multiple lines by line feeds. I wanted to concatenate those lines into a single line.

      Pasted the key text into a new tab, selected the lines and issued a Ctrl-J. This resulted in a single line, but each LF was replaced by a space.

      This is in v8.9.6.4 (64-bit) on Win 11.

      DougK.AZD 1 Reply Last reply Reply Quote 0
      • guy038G Online
        guy038
        last edited by guy038

        Hello, @dougk.az and All,

        I suppose that using this simple regex replacement, below, should work !

        • Open your text in N++

        • Move back at the very beginning of your file

        • Open the Replace dialog ( Ctrl + H )

        • Uncheck all box options

        • FIND \r\n?

        • REPLACE Leave EMPTY

        • Check the Wrap around option

        • Select the Regular expression search mode

        • Click, once, on the Replace All button

        Here you are !


        To verify that all your lines are just concatenated, without any char in between, simply use the ¶ icon of the Toolbar. All the LF characters are preserved !

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 0
        • DougK.AZD Offline
          DougK.AZ @DougK.AZ
          last edited by

          Thanks guy for the hint. There are no CR’s in this file, only LF’s, so an “extended” search on \n replacing with nothing did the trick!

          1 Reply Last reply Reply Quote 0
          • guy038G Online
            guy038
            last edited by

            Hi; @dougk.az and All,

            First of all, I need to apologize :

            Firstly, my search regex was erroneous. My bad ! I should have written :

            FIND \r?\n

            REPLACE Leave EMPTY


            Secondly, in the last sentence of my previous post, I did a typo because I wanted to mean :

            To verify that all your lines are just concatenated, without any char in between, simply use the ¶ icon of the Toolbar. All the FF characters are preserved !


            Note that the regex syntax \r?\n search, either, for :

            • The two consecutive chars \r and \n

            • The character \n only

            So, this new formulation, in regex mode, should work either !

            BR

            guy038

            1 Reply Last reply Reply Quote 0
            • DougK.AZD Offline
              DougK.AZ
              last edited by

              No worries. I had no trouble using search/replace to join the lines. My purpose with this posting was just to let the developers know that Ctrl-J is not working as I expected.

              Doing a bit more research it seems that Ctrl-J works similarly to Shift-J in gVim. What I was expecting is the 2nd option below, which is not the default.

              In gVim:
              J: Joins the current line and the next line, inserting a space.
              gJ: Joins the lines without adding any spaces or removing existing whitespace.

              So this more or less explains why the space was inserted.

              Doug

              PeterJonesP 1 Reply Last reply Reply Quote 0
              • PeterJonesP Online
                PeterJones @DougK.AZ
                last edited by

                @DougK.AZ said:

                My purpose with this posting was just to let the developers know that Ctrl-J is not working as I expected.

                FYI, this behavior is as it is documented in the User Manual at https://npp-user-manual.org/docs/editing/ :

                046c19c2-e5a8-4a81-b719-87aa6944d9ba-image.jpeg

                …

                And regarding @guy038’s regex: I am surprised he didn’t suggest the simpler FIND of \R – the capital version of the escape sequence will match \r\n or \r or \n, so it handles any of the normal line endings, without having to add in the ?, so that would have been a simpler regular-expression FIND WHAT value to use.

                DougK.AZD 1 Reply Last reply Reply Quote 1
                • DougK.AZD Offline
                  DougK.AZ @PeterJones
                  last edited by

                  RTFM is always the last option. :) Thanks for pointing that out and thanks to everyone that replied to this posting.

                  Doug

                  1 Reply Last reply Reply Quote 0
                  • guy038G Online
                    guy038
                    last edited by

                    Hi, @dougk.az, @peterjones and All,

                    Oh, yes, Peter, you’re perfectly right ! But I must be a little tired from this heat wave. Since June 22, in the room where my desk is, even with a fan, the temperature has usually been between 29 °C and 30.5 °C. It’s awful !

                    BR

                    guy038

                    1 Reply Last reply Reply Quote 0

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors