TransWikia.com

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

Super User Asked by falsky on November 18, 2021

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

7 Answers

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.

Answered by lasantha dharmasiri on November 18, 2021

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

Answered by Viktor Mellgren on November 18, 2021

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.

Answered by banavalikar on November 18, 2021

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

Answered by Denham Coote on November 18, 2021

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:
    • rn 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
    • 1rn for Windows
    • 1r for older versions of MacOS (9 or older)
    • 1n for Unix or newer of MacOS (OS X or newer)
  5. Enable "Extended"
  6. Click "Replace All"

Answered by WernerCD on November 18, 2021

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

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

  • Set "Find what" to rn

  • Set "Replace with" to 1rn

  • 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, rn.

  • 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 rn for Unix/OS X EOLs ("Find what" is n, "Replace with" is 1n)

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


Further reading

Answered by DavidPostill on November 18, 2021

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.

Answered by Zaheylu on November 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP