How do I add a number at the end of every line in Notepad++?

Solution 1:

How do I add a number at the end of every line in Notepad++?

  • Menu "Search" > "Replace" (or Ctrl + H)

  • Set "Find what" to \r\n

  • Set "Replace with" to 1\r\n

  • Enable "Regular expression" or "Extended"

    Note - "Regular expression" is a superset of "Extended" so in this particular case it doesn't matter which one you use.

  • Click "Replace All"

Enter image description here

Notes:

  • The above assumes you are editing a text file with Windows EOLs, \r\n.

  • If you are using files with different EOLs you can convert them to Windows EOLs using Menu "Edit" > "EOL Conversion".

  • If you aren't working with Windows EOL, and you don't wish to convert them, use the following instead:

    • Use \n instead of \r\n for Unix/OS X EOLs ("Find what" is \n, "Replace with" is 1\n)

    • Use \r instead of \r\n for Mac OS (up to version 9) EOLs ("Find what" is \r, "Replace with" is 1\r)


Further reading

  • Notepad++: A guide to using regular expressions and extended search mode

Solution 2:

Another option is the record and playback feature.

  1. With your cursor on the first line, Click on 'Start Recording'
  2. Type End, 1,
  3. Click on 'Stop Recording'
  4. Click on 'Run a Macro Multiple Times...'
  5. Select 'Run until the end of file' and click Run
  6. Job done

Screenshots

record and playback

Type End, 1,

Click on stop

Run Macro

enter image description here

Done

Solution 3:

Updated answer:

Hit Ctrl + H for opening the Replace Dialog.

Under search mode, tick Regular Expression.

Find what: $

Replace with: 1

And hit Replace all


Original answer

Hit Ctrl + H for opening the Replace Dialog.

Under search mode, tick Regular Expression.

Find what: ^.*$

Replace with ($0)1

And hit Replace all

Explanation

You are searching for the regular expression ^.*$, which is esentially every line. ^ marks the beginning of a line, .* includes any character any number of times and $ marks the end of the line. Thus, this regular expression finds all content on every line.

We replace this expression with ($0)1, $0 being the found expression, and appending a 1 to it.

Solution 4:

Or do it like the big boys do :).

Select the last column using Shift + Alt => right key (once) => down key (press till the last line).

Type whatever you want. It will appear on all lines at once.