In Vim,
How do i add a word at the beginning of all lines?
Also how do i add it at end?
Eg..
If i have
A
B
C
D
I want to make it to
int A =
int B =
etc..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
use visual block mode (Ctrl–v) to select the column you want, and then hit I, type the characters you want, and then hit Esc
So in this case, you’d put your cursor on
A, hit Ctrl–v, go down toD, hit I and typeint(it’ll only appear on the first line while you type it), and then hit Esc at which point it’ll apply that insert to all visually selected portions.This works for anywhere in the document, beginning of line or end of line.
:he v_b_Ifor more info on Visual Block Insert