Skip to content

VSCode Vim Cheatsheet

Posted on:August 6, 2020 at 06:00 PM

Setup

Search for the Vim plugin in VSCode and install it.

VSCode Vim specific

key combinationcommand
ghShow tooltip
ctrl + shift + mshow errors in file
vj"+ycopy to clipboard on Linux
ctrl + shift + vpaste in vim from clipboard
f12go to defintion
f2rename
ctrl + shift + g > tab > j > spacesee git diffs and preview them by pressing j and k after tabbing to the files. Space to preview

Just Vim

key combinationcommand
ctrl + [go to “normal” mode
wmove a word forwards
bmove a word backwards
:q!exit file without saving
amove 1 to the right and enter “insert” mode
shift + Igo to the start of a line and enter “insert” mode
shift + Ago to the end of the line and enter “insert” mode
/enter command mode and search for text
ngo to the next occurence after searching for text
Ngo to the previous occurence after searching for text
\*same as “n” but for what is currenlty under your cursor
#same as “N” but for what is currently under your cursor
:'<,'>s/foo/bar/greplace all occurences of “foo” with “bar” for a given selected text
f<char>jump to “char”
t<char>jump before “char”
; and ,after using f or s you can use these to jump through results
^move to the beginning of a line
$move to the end of a line
xdelete one character
sdelete one character and enter “insert” mode
cjust like d but after deleting it goes into “insert” mode
shift + ddelete the rest of the content on the line
shift + sdelete the entire line and move into “insert” mode while properly indented
gggo to the top
Ggo to the bottom
:100go to line 100
12jgo down 12 lines
4wforward 4 times (turn on relative line numbers)
\}go to the next empty line
\{go to the previous empty line
ctrl + upage up
ctrl + dpage down
%jump between matching {} or () or []
di<char>delete the content between the given characters, like {}, (), "", ”, “ etc.
rreplace inline
Rreplace inline until escape
ctrl + aincrement a number
ctrl + xdecrement a number
ctrl+r "paste yank to command mode

Vim Combos

key combinationcommand
dt<char>delete up to a specific character
j5f\{%jump to end of the first line of a function and then jump to end of function
ci"delete the text between "" (you don’t even have to be within the quotes!)
yiWyank the current word
dipdelete continuous code block

Commands

key combinationcommand
:Ex %create new file after opening explorer
:g/{pattern}/{command}execute a command on every line that matches the pattern
:s/{pattern}/{replacement}/gcreplace all occurences of pattern with replacement. C flag means you need to confirm each replacement

Plugins

Additional resources