how to append lines with a comma or other cha

2. Help
  • I've been using NP for a while but still have lots to learn.

    Just curious if there are any tools to append a series of lines with a character .

    Also, what is easiest way to search and replace/remove line breaks in a text file.


    • pshute

      I recommend Advanced fnd/replace (control+r) without regex.  See for details.

    • Don HO
      Don HO

      > Or just search the forums for similar messages and answers. There are a lot!

      If you don't want to answer the question, just don't bother to answer it.
      I'll remove such unfriendly post from now on.


      • That's funny. I keep reading the same answers and comments to the same messages over and over again. Would you end up removing all the questions as well?

    • Take a look at this similar question, involving inserting text at the beginning of each line:

      "Insert Filename and Macro"

      Notice that in regex mode you can scan for the end of a line by using $ at the end of the regex.

      You can select the lines to work on in advance.
      Press CTRL+F or CTRL+R. Check if the Selection checkbox is checked then.

      Find field:
      Replace field:
      Regular expression: checked.

      Notice that this will NOT work for EMPTY lines, because in regex mode a real selection has to be made in order to replace it.

      In normal mode you can use CTRL+R advanced Find/Replace dialog to enter linebreaks by CTRL+M, SHIFT+Enter or CTRL+Enter. You can simply search for them and replace them the same way.

      Find field:
      Insert the linebreak (CTRL+M or SHIFT+Enter or CTRL+Enter)
      Replace field:
      ,CTRL+M (append a linebreak to the comma)

      Replace all occurrences.

      Notice that this method may not work for the last line of your file, as it may not have a linebreak. (Why do we call these things "End-of-line"? If it's not there, the line still ends...)

      • Correction: in regex mode the found character should be grouped.

        Find field:

        This way the \1 will contain and put back the found character, instead of nothing.
        This avoids _replacing_ the last character by a comma, instead of appending that.

        • Fool4UAnyway

          Also here, the CTRL+H Replace dialog will find a match (and replace/add) on the same line over and over again.

          Use the CTRL+R advanced Find/Replace dialog.

  • hi all, very newbie to all this, but somehow i have successfully inserted comma in every line and i want to put them all in once single row, suggest me how do i do that?

    for example:

    how to put  it in single line, 123456789,987654321,234567891,345678912,

    Awaiting your help/