My favorite Vim combos

With demonstration gifs

John Feng
3 min readFeb 8, 2024

I have been using Vim keybindings in VScode for last few months. Here are some combos that I recently found and absolutely love doing. I added recorded some gifs to help visualize the effects of these vim combos. Enjoy :)

Tricks with ci and ca

ciw or caw for changing a word quickly. The difference is a will include the space after the word, and i will only change the word.

ci or ca followed by (, {, [, ", ' jump the and change everything inside the brackets/quotes (including brackets if ca used). The beauty of this is you don’t need to move your cursor to the section you are changing, as long as your cursor is on the same line.

ci( to change everything inside the first set of brackets

In the case where there is more than one matching pair or brackets/quotations, by default the command would apply to the first pair. If you want to apply the change to other pairs, you would need to move the cursor there. The weird things is, if the cursor is placed past the 1st bracket but not inside the 2nd, it will delete the contents inside the first bracket pair, but place the insert where the cursor originally is.

ci{ at the beggining of the line
ci{ in between two { } pairs
ci{ on the second pair

Surround Input

ysiw followed by a character such as (, {, [, ", ' to surround a word in opening and closing brackets or quotes. ysaw does the same thing, but includes one space before the word. There seems to be no difference between small or big w.

ysiw “
ysaw “

ysip will apply the surround input on a whole paragraph.

ysap {

--

--

John Feng
John Feng

Written by John Feng

Data Scientist | ML Engineer | PhD in Physics

Responses (2)