Skip to content

Instantly share code, notes, and snippets.

@saurbhc
Last active July 4, 2022 23:24
Show Gist options
  • Save saurbhc/763965b3229a1299ea66af5db9ca7598 to your computer and use it in GitHub Desktop.
Save saurbhc/763965b3229a1299ea66af5db9ca7598 to your computer and use it in GitHub Desktop.
vim — Keyboard Shortcuts (which are actually used)
gg -> takes you to the top of the file
G -> takes you to the bottom of the file
{ -> goes down (skip) down a block of code
} -> goes up (skip) down a block of code
(Number) (command) -> will do that command that many times.
Example 50 } -> will take you down 50 blocks.
Example 50 { -> will take you up 50 blocks.
:(line-number) go to a specific line
Example :30 -> will take you to 30th line
Example :0 -> will take you to 0th line
dd -> delete a line
u -> undo
control+r -> redo
yy -> copy line
p -> paste line below
P -> paste line above
dd -> delete the line & copy to clipboard
v -> visual mode
(v) then shift+} -> selects a block
(v) then d -> deletes the selected text
o -> adds new line below and puts you inside insert mode
O -> adds new line above and puts you inside insert mode
w -> go through a word forward
W -> go through a word forward (ignores punctuation)
b -> go through a word backwards
B -> go through a word backwards (ignores punctuation)
0 -> takes you to the beginning
^ -> takes you to the first word of the line (easy command below)
0w -> takes you to the first word of the line (emulates above command)
$ -> takes you to the end of line
t! -> go to before exclamation (or any character)
f! -> go to exclamation (or any character)
% -> takes you to the next same character
d% -> deletes everything in b/w the next same character
cw -> change word (replace)
ct} -> change everything until }
dt} -> delete everything until }
* -> take the cursor to the word
** -> toggle the cursor to the instances of the word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment