How do I append the same text to the end of several lines?
Answer
V select then :norm A text
Explanation
Selecting lines and running :norm A text appends the same text to the end of every selected line. This is often simpler than visual block mode.
How it works
- Select lines with
Vand motions - Type
:(auto-fills'<,'>) - Type
norm A;(or whatever text to append) - Press Enter
Example
let x = 1
let y = 2
let z = 3
Select all three lines, run :'<,'>norm A;:
let x = 1;
let y = 2;
let z = 3;
Tips
norm I//prepends//to each linenorm!uses built-in key meanings (ignores custom mappings)- More flexible than block mode for lines of different lengths
:%norm A;applies to every line in the file- Works with any normal mode command, not just A/I