I have 23,000 lines, and I need to add the number 1 at the end of every line.

How can I do this?

Right now:


What I would want:

  • 2
    More interesting; how would you assign sequential numbers to sequential lines? :-) Jul 19, 2015 at 23:27
  • 1
    @CarlWitthoft Number the lines with the TextFX package (TextFx > TextFx Tools > Insert Line Numbers) and then move the line numbers to the EOL with a regexp.
    – DavidPostill
    Jul 20, 2015 at 9:30
  • 2
    If there is an empty line between 2 text lines, should that line also get a 1?
    – Nzall
    Jul 20, 2015 at 12:16
  • 4
    :%s/$/1/. Oh wait, that's Vim. ;-) (Which is available for Windows as well.)
    – DevSolar
    Jul 21, 2015 at 11:23
  • 1
    @DevSolar Alternatively, :g/$/norm A1. Or the more complex but fancier gg$<C-v>G$A1<esc>. Or even the admittedly obnoxious ggqqqqqA1<esc>j@qq@q. More than one way to do it :P
    – Doorknob
    Jul 22, 2015 at 1:18

7 Answers 7


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


  • 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

  • This only works if the line delimiter is windows, \r\n.
    – Zaheylu
    Jul 19, 2015 at 13:40
  • 5
    Yes, but Notepad++ is a WIndows program ... ;)
    – DavidPostill
    Jul 19, 2015 at 13:42
  • 5
    Oh you're right ... :) Still, the text file could have other line ending coding ;)
    – Zaheylu
    Jul 19, 2015 at 13:43
  • 5
    If you aren't working with windows EOL, there is no reason to "convert" them... just use \n or \r instead (Unix and Mac EOLs respectively). \n => 1\n or \r => 1\r. I do this kinda stuff more often with Extended instead of Regex personally.
    – WernerCD
    Jul 19, 2015 at 18:21
  • 2
    @WernerCD Should be noted that a single \r only applies to the defunct Mac OS. Not OS X, which uses \n.
    – Bob
    Jul 20, 2015 at 7:23

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


record and playback

Type End, 1,

Click on stop

Run Macro

enter image description here


  • 9
    Notepad++ macros never get enough love.
    – armani
    Jul 20, 2015 at 19:46

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


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.

  • 4
    Find = $ and replace = 1 is sufficient.
    – Salman A
    Jul 21, 2015 at 11:18

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.

  • I was going to say this as well .. why all the complex reg expresssion? this answers the question perfectly .. and why the down vote ? because somebody just didn't understand that it's a valid answer? O.o
    – Ditto
    Jul 20, 2015 at 18:29
  • 2
    This may not be practical for 23,000 lines (too slow or otherwise (memory problems due to Shlemiel the painter's algorithms?)). Have you actually tried it on 23,000 lines? Jul 20, 2015 at 21:49
  • 2
    @PeterMortensen Horrifically slow, but memory usage is fine (5 MB => 25 MB). The bigger issue is that it doesn't seem to cope well with differing line lengths.
    – Bob
    Jul 21, 2015 at 5:31
  • @Ditto I make no claim to be an average user, but this seems considerably less intuitive than regular expressions. Then again, xkcd.com/1171
    – David Z
    Jul 21, 2015 at 12:52
  • 1
    This isn't a very good answer, first you would need to find the longest line, then you would need to press down till the last line, while testing this method I got bored after a couple dozen lines, I could not sit there for 20k+ lines
    – Aequitas
    Jul 23, 2015 at 5:35

Extended Mode.

I wanted to add a slightly different approach that's not mentioned in other answers: Extended Mode.

For something like this - where all you are concerned with are \r, \n, \t or others included in this small list (although that page looks to be "dated", so not 100% sure on its veracity) there is no reason to go full out regular expression.

I use Notepad++'s extended mode "often" to massage file layouts - mainly centering around remove multiple empty lines, extra whitespace and other assorted oddities.


  1. Menu "Search" > "Replace" (or Ctrl + H)
  2. Determine which line endings you want
  3. In "Find What" put:
    • \r\n for Windows
    • \r for older versions of MacOS (9 or older)
    • \n for Unix or newer of MacOS (OS X or newer)
  4. Set "Replace with" to
    • 1\r\n for Windows
    • 1\r for older versions of MacOS (9 or older)
    • 1\n for Unix or newer of MacOS (OS X or newer)
  5. Enable "Extended"
  6. Click "Replace All"
  • "Regular expression" is a superset of "extended" so in this particular case is doesn't matter which one you use.
    – DavidPostill
    Jul 20, 2015 at 14:25
  • Shouldn't it be \n for Unix and \r for older version of MacOS? First bullet from Wikipedia: en.wikipedia.org/wiki/Newline#Representations
    – nhahtdh
    Jul 21, 2015 at 2:39

If it is equally long strings, then you can hold Alt and click and drag to block select and be able to write on several lines at the same time. If they are not equally long, but not space separated, you can't do the same procedure and then replace " " with "".

  • 3
    I sometimes use this feature, but dragging for 23,000 lines... Not so much fun :) Jul 22, 2015 at 9:12

This way is lot easier in notepad++

Steps -:
1.Click end of first line.
2.Click ALT + C.
3.Fill what you want
4.Click ok.

  • This will only work if all lines are of same length.
    – Toto
    Jul 22, 2020 at 8:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .