Notepad++;Insert Multiple line of Words between Lines at once, How do I get this result?
-
I want to Insert/Add/Cut&Paste Multiple line of Words between the lines at once, How do I get that done?
- The Case;
- What I want to get;
-
I think you do this using the find-and-replace (CTRL+H)
Find what: \r\n\r\n Replace with: \r\n
The
\r
is the CR=carriage return character (ascii 13) and\n
is the line feed (ascii 10). So this replaces a double <cariage return><line feed> (=empty line) with one single <cariage return><line feed>.Under Search mode be sure that “Extended” is selected. Btw this also depends on the newline type file of your type, see bottom right in Notepad++, Windows=CR/LF or for Unix=LF.
And for sorting, you can go to the menu
Edit -> Line operations -> Sort Lines Lexicographically Ascending
-
@joe-junior said,
I want to Insert/Add/Cut&Paste Multiple line of Words between the lines at once, How do I get that done?
The assumption, based on your example data, is that you want to sort. If that’s the case, then follow the advice already given (though I’d say sort first, then Edit > Line Operations > Remove Empty Lines rather than trying to do it as a search/replace).
However, if what you really want is to interleave lines , I would suggest making use of Column Editor and sorting.
… and as I was writing up the instructions, the original post was deleted. It is considered exceedingly rude to delete a post after there is at least one reply to it. As such, a moderator has undeleted your post.
The general procedure would have been something like "column select from the first line of the first group to the last line of the first group (Edit > Begin/End Select in Column Mode being your friend, if you don’t want to just use
Alt+Click+Drag
), then Edit > Column Editor (Alt+C
), Initial Number=2
, Increment By=2
; similar with the second group, except Initial Number=1
– this makes the first group 2/4/6/… and the second 1/3/5/… Then use lexicographical sort. Then use column select again and delete the numbers (or use a regex like^\h*\d+\h*
and replace with nothing) … -
@Bas-de-Reuver Notepad++'s regular expression search/replace has a couple of things that you and others may find useful.
\R
matches any style of newline such as CR, LF, and CRLF. While \R does not work in the replacement part it’s still useful.You can remove blank lines using
^\R+
You can remove spurious blank lines using^\R\K\R+
The\K
says to keep everything to the left meaning it will keep one blank line while removing spurious blank lines.In both cases it’s a regular expression search/replace with the replace part being nothing or blank. This also means we don’t care about the current end of line format as
\R
matches any of them and\K
ends up keeping whatever end-of-line style is in use.It’s not clear from the OP’s example if they desired to remove the blank lines and then sort the resulting list or if they desired to have some sort of combining, merging, or interleaving of the lines that may or may not be sorted. As the OP then wanted to delete the thread it will likely forever remain a mystery.