Van Nguyen
Van Nguyen

Reputation: 21

Add quotations in multiple lines with vim

I forgot to enclose the keys in the dictionary with single quotes. What's the fastest way to do this with vim?

fName: 'Please enter your full name:',
employed: "Are you employed (enter 'y' for yes and 'n' for no)?",
salary: 'Please enter your current salary:',
incRate: 'Please enter your percent pay increase:'

Currently, these are my steps.

Go to beginning of 'fName', insert mode, insert ', w command, insert ', down j command, back word b command, repeat above.

Thanks for the help!

Upvotes: 1

Views: 1666

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172510

Many people use the surround.vim plugin for that. With it, you can surround the current word with ysiw'. (ys - surround, iw - inner word, ' - with single quotes). With repeat.vim, you can apply this to following lines via j..

Upvotes: 3

romainl
romainl

Reputation: 196476

One way:

ciw'<C-r><C-o>'<Esc>
2_.   or j0.
2_.
2_.

Reference:

:help c
:help iw
:help i_ctrl-r_ctrl-o
:help _

Upvotes: 1

Related Questions