Notepad++ add to every line
Follow these steps:
- Press Ctrl+H to bring up the Find/Replace Dialog.
- Choose the
Regular expression
option near the bottom of the dialog.
To add a word, such as test
, at the beginning of each line:
- Type
^
in theFind what
textbox- Type
test
in theReplace with
textbox- Place cursor in the first line of the file to ensure all lines are affected
- Click
Replace All
button
To add a word, such as test
, at the end of each line:
- Type
$
in theFind what
textbox- Type
test
in theReplace with
textbox- Place cursor in the first line of the file to ensure all lines are affected
- Click
Replace All
button
- Move your cursor to the start of the first line
- Hold down Alt + Shift and use the cursor down key to extend the selection to the end of the block
This allows you to type on every line simultaneously.
I found the solution above here.
I think this is much easier than using regex.
Notepad++ has a very powerful editing capability. (Today I'm searching for the similar function in Sublime Text), but for Notepad++, just hold Alt when you drag the mouse. What you type will then replace the selected column on every line. To insert without replacing existing text, use Alt-Shift.
Here is my answer. To add ');' to the end of each line I do 'Find What: $' and 'Replace with: \);' you need to do escape;
You can automatically do it in Notepad++ (add text at the beginning and/or end of each line) by using one regular expression in Replace (Ctrl+H):
Explanation: Expression $1
in Replace with input denotes all the characters that include the round brackets (.*)
in Find what regular expressin.
Tested, it works.
Hope that helps.