Notepad++

Advanced Search and Replace

Author

George Wong

Date, Revisions

Created on 21 July, 2017

Abstract

Eliminating line breaks from text using extended mode of Search and Replace in Notepad++.

Summary

I currently have a task that requires the removal of a large number of line breaks and then replacing it with a comma ','. This is a repetitive and boring task if done manually so I've discovered that notepad++ (my favourite text editor) can do this very easily.

An example below of a group of database keys:

    45177
    37525
    38350
    37230
    45176
    45217
    45216
    45218
    45230
    45229
    45224
    45220
    45185
    45184
    45183
    45182
    45181
    45214
    45209
    

Making them into this format:

    45177,37525,38350,37230,45176,45217,45216,45218,45230,45229,45224,45220,45185,45184,45183,45182,45181,45214,45209
    

Practical for a number of applications, but especially when you have 7000+ records!

Here are the steps to do it:

  1. Copy the list from your source (like from spreadsheet) to Notepad++.


  2. Place the cursor at the end of the first line.

  3. Press CTRL+H (Replace)


  4. In the Find what: box type this expression \r\n.
    For the above expressions \r is 'Carriage Return' and \n is 'Line Feed'.
    For more info refer to the Notepad++ documentation.

  5. In the Replace with: box type ,

  6. Make sure you've checked Extended Mode under Search Mode

  7. Execute Replace All

Now the text should update:

Larger example with about 2000 records (clicky):