Add a string to every line of a selection
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Flying Over Ancient Lands
--
Chapters
00:00 Add A String To Every Line Of A Selection
00:22 Answer 1 Score 5
00:32 Accepted Answer Score 17
01:06 Answer 3 Score 7
01:38 Answer 4 Score 4
02:16 Thank you
--
Full question
https://superuser.com/questions/351121/a...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#notepad++
#avk47
ACCEPTED ANSWER
Score 17
Note: I misread the question initially, so I've posted this as a comment instead as it's still potentially useful but not an answer
One method that doesn't involve find/replace (but only works if you want to do it on every line, including blank lines in your block), is this:
- 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
ANSWER 2
Score 7
- Choose Search -> Find
- Select the Replace tab
- Choose Regular expression as Search Mode in the bottom left
- Enter as Find what: $
- Enter as Replace with: the string you want to have at the end of the lines
- Check In selection
- Click Find Next or Replace All
This site is nice for testing regular expressions and has a quick reference:
ANSWER 3
Score 5
Replace the regular expression $
with the string you want.
ANSWER 4
Score 4
Alternatively,
- Choose Search -> Replace
- Choose Extended for Search Mode
- Find what: \n
- Replace with: Whatever\n
Note that if you leave off the \n in the Replace with, all your lines will be pasted together (which is probably not what you want).
I usually leave Notepad++ in Extended mode because it allows me to optionally paste lines to gether (by removing \n) or split them (by inserting \n), and doesn't get confused by special characters like *+() etc. (Which I am often searching for in C++ code.)