Add a string to every line of a selection

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

Does anyone know how to append a string to every line of a selection?


Solution 1:

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

Solution 2:

  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/