Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

To prepend a string to every line of a selection, I usually use the "increase line indent" (which add tab to every line) and then run a search for tab / replace with my string.

Anyone know how I append a string to every line of a selection?

share|improve this question
2  
One method of doing the prepend that doesn't involve find/replace is to 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 –  Simon Oct 27 '11 at 9:26
    
very useful use it all the time now / please post as answer and I accept –  Muleskinner Feb 28 '12 at 9:19
    
I've undeleted my answer below –  Simon Feb 28 '12 at 12:06
add comment

5 Answers 5

up vote 4 down vote accepted

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

share|improve this answer
    
Thanks, did not find an answer to my specific question but this solved my problem / very useful. –  Muleskinner Feb 28 '12 at 12:29
    
@Simon Simply superb –  prabhakaran May 27 '12 at 10:33
add comment

Replace the regular expression $ with the string you want.

share|improve this answer
    
it gives me "The regular expression to search is formed badly", how should I format the $? –  Muleskinner Oct 27 '11 at 9:39
add comment
  1. Choose Search -> Find
  2. Select the Replace tab
  3. Choose Regular expression as Search Mode in the bottom left
  4. Enter as Find what: $
  5. Enter as Replace with: the string you want to have at the end of the lines
  6. Check In selection
  7. Click Find Next or Replace All

This site is nice for testing regular expressions and has a quick reference:

http://rubular.com/

share|improve this answer
    
But ^ is start of line, guess you mean $? But anyway, both gives me "The regular expression to search is formed badly" –  Muleskinner Oct 27 '11 at 9:53
    
Still gives me "The regular expression to search is formed badly", im using Notepad++ v.5.6.4 (unicode) –  Muleskinner Oct 27 '11 at 10:25
    
Yes, I read your question wrong first, but then I updated my answer. Don't know what it is, then. I have Notepad++ 5.9.3 on Windows 7. Maybe you can try upgrading, in case this error is specific to your version of Notepad++? Also maybe you can try to search for regular expression "a" or "." to see if it is regular expressions in general that don't work in your setup. –  kek Oct 27 '11 at 10:43
add comment

Alternatively,

  1. Choose Search -> Replace
  2. Choose Extended for Search Mode
  3. Find what: \n
  4. 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.)

share|improve this answer
add comment

This can be done using notepad++. Its explained here step by step. http://dotnet-programming-solutions.blogspot.ae/2012/11/how-to-add-text-to-beginning-or-end-of.html Basically its a regular expression match and replace. It is so simple as find->replace all.

share|improve this answer
    
This adds nothing that has not already been said. –  teylyn Mar 11 '13 at 7:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.