Glam Prestige Journal

Bright entertainment trends with youth appeal.

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:

[line1]TEXT
[line2]TEXT

What I would want:

[line1]TEXT1
[line2]TEXT1
9

7 Answers

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

16

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

1

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.

1

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.

7

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.

Extended

  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"
2

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

1

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.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy