Ctrl-J (join lines) replaces LF with space
-
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.
-
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 aroundoption -
Select the
Regular expressionsearch mode -
Click, once, on the
Replace Allbutton
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 theLFcharacters are preserved !Best Regards,
guy038
-
-
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!
-
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?\nREPLACE
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 theFFcharacters are preserved !
Note that the regex syntax
\r?\nsearch, either, for :-
The two consecutive chars
\rand\n -
The character
\nonly
So, this new formulation, in regex mode, should work either !
BR
guy038
-
-
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
-
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/ :

…
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\nor\ror\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. -
RTFM is always the last option. :) Thanks for pointing that out and thanks to everyone that replied to this posting.
Doug
-
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 between29 °Cand30.5 °C. It’s awful !BR
guy038
Oh ! Now, I also realized that @dougk.az never spoke about the form feed (
FF) characters, of code\x0Cbut spoke about the line feed (LF) chars, of code\x0AAs I said above : really tired by heat !!!
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