Setup
Search for the Vim plugin in VSCode and install it.
VSCode Vim specific
key combination | command |
---|
gh | Show tooltip |
ctrl + shift + m | show errors in file |
vj"+y | copy to clipboard on Linux |
ctrl + shift + v | paste in vim from clipboard |
f12 | go to defintion |
f2 | rename |
ctrl + shift + g > tab > j > space | see git diffs and preview them by pressing j and k after tabbing to the files. Space to preview |
Just Vim
key combination | command |
---|
ctrl + [ | go to “normal” mode |
w | move a word forwards |
b | move a word backwards |
:q! | exit file without saving |
a | move 1 to the right and enter “insert” mode |
shift + I | go to the start of a line and enter “insert” mode |
shift + A | go to the end of the line and enter “insert” mode |
/ | enter command mode and search for text |
n | go to the next occurence after searching for text |
N | go 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/g | replace 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 |
x | delete one character |
s | delete one character and enter “insert” mode |
c | just like d but after deleting it goes into “insert” mode |
shift + d | delete the rest of the content on the line |
shift + s | delete the entire line and move into “insert” mode while properly indented |
gg | go to the top |
G | go to the bottom |
:100 | go to line 100 |
12j | go down 12 lines |
4w | forward 4 times (turn on relative line numbers) |
\} | go to the next empty line |
\{ | go to the previous empty line |
ctrl + u | page up |
ctrl + d | page down |
% | jump between matching {} or () or [] |
di<char> | delete the content between the given characters, like {}, (), "", ”, “ etc. |
r | replace inline |
R | replace inline until escape |
ctrl + a | increment a number |
ctrl + x | decrement a number |
ctrl+r " | paste yank to command mode |
Vim Combos
key combination | command |
---|
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!) |
yiW | yank the current word |
dip | delete continuous code block |
Commands
key combination | command |
---|
:Ex % | create new file after opening explorer |
:g/{pattern}/{command} | execute a command on every line that matches the pattern |
:s/{pattern}/{replacement}/gc | replace all occurences of pattern with replacement. C flag means you need to confirm each replacement |
Plugins
Additional resources