• Login
Community
  • Login

Notepad++;Insert Multiple line of Words between Lines at once, How do I get this result?

Scheduled Pinned Locked Moved General Discussion
4 Posts 4 Posters 2.4k 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.
  • J
    joe junior
    last edited by Oct 17, 2023, 5:48 AM

    I want to Insert/Add/Cut&Paste Multiple line of Words between the lines at once, How do I get that done?

    1. The Case;

    1.notepad++ Insert Line With Words Betwen Lines.png

    1. What I want to get;

    2.notepad++ Insert Line With Words Betwen Lines.png

    1 Reply Last reply Reply Quote 0
    • B
      Bas de Reuver
      last edited by Oct 17, 2023, 10:14 AM

      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

      P M 2 Replies Last reply Oct 17, 2023, 1:15 PM Reply Quote 0
      • P
        PeterJones @Bas de Reuver
        last edited by PeterJones Oct 17, 2023, 1:17 PM Oct 17, 2023, 1:15 PM

        @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) …

        1 Reply Last reply Reply Quote 0
        • M
          mkupper @Bas de Reuver
          last edited by Oct 17, 2023, 4:54 PM

          @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.

          1 Reply Last reply Reply Quote 1
          3 out of 4
          • First post
            3/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors