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]TEXTWhat 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\nSet "Replace with" to
1\r\nEnable "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"
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
\ninstead of\r\nfor Unix/OS X EOLs ("Find what" is\n, "Replace with" is1\n)Use
\rinstead of\r\nfor Mac OS (up to version 9) EOLs ("Find what" is\r, "Replace with" is1\r)
Further reading
16Another option is the record and playback feature.
- With your cursor on the first line, Click on 'Start Recording'
- Type End, 1, ↓
- Click on 'Stop Recording'
- Click on 'Run a Macro Multiple Times...'
- Select 'Run until the end of file' and click Run
- Job done
Screenshots
Type End, 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.
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.
7Extended 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.
- Menu "Search" > "Replace" (or Ctrl + H)
- Determine which line endings you want
- In "Find What" put:
\r\nfor Windows\rfor older versions of MacOS (9 or older)\nfor Unix or newer of MacOS (OS X or newer)
- Set "Replace with" to
1\r\nfor Windows1\rfor older versions of MacOS (9 or older)1\nfor Unix or newer of MacOS (OS X or newer)
- Enable "Extended"
- Click "Replace All"
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 "".
1This 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.