This cheat sheet is very opinionated and it summarises keymaps that I find important and useful. These keymaps are default keymaps which means they work out of the box with Vim as well as Vim extensions on other editors.
This cheat sheet also contains examples where I would showcase how I use these keymaps.
Note: C-a
denotes Ctrl + a and {...}
denotes a parameter. Although my key bindings don't really use Ctrl a lot, I still recommend mapping Ctrl to a convenient key, such as Caps Lock.
To exit from Insert mode, do C-[
.
To exit from Visual mode, do v
.
To exit from Visual Line mode, do V
.
From this point onwards, "Visual mode" will refer to both Visual and Visual Line modes.
Key |
Description |
h |
left |
l |
right |
Key |
Description |
k |
up |
j |
down |
gg |
go to first line |
G |
go to last line |
Key |
Description |
e |
one word forward |
b |
one word backward |
Key |
Description |
/{re} |
search for pattern |
* |
search for identifier under cursor |
n |
next search result |
N |
previous search result |
Key |
Description |
% |
Find matching parenthesis, bracket or brace |
Key |
Description |
C-d |
scroll down |
C-u |
scroll up |
Key |
Description |
A |
append text at end of line |
i |
insert text before cursor |
I |
insert text at start of line (ignoring whitespace) |
o |
open new line below cursor |
O |
open new line above cursor |
Key |
Description |
x |
delete character under cursor |
d |
delete (in Visual mode) |
daw |
delete word |
dd |
delete line |
D |
delete until end of line |
Key |
Description |
y |
yank (in Visual mode) |
yy |
yank line |
p |
put after cursor |
P |
put before cursor |
Key |
Description |
r |
change character |
s |
delete character and enter Insert mode |
c |
change (in Visual mode) |
ce |
change until end of word |
cc |
change line |
C |
change until end of line |
< |
left indent (in Visual mode) |
<< |
left indent line |
> |
right indent (in Visual mode) |
>> |
right indent line |
Key |
Description |
v |
start or stop highlighting characters |
V |
start or stop highlighting lines |
C-v |
start or stop highlighting a rectangular area |
Key |
Description |
. |
repeat last content change |
Key |
Description |
u |
undo |
C-r |
redo |
Text Objects
I use these a lot but didn't put them in this cheat sheet because I want this cheat sheet to be less intimidating.
This is a must-know!
/* from this */
p {
font-size: large;
}
/* to this */
p {
color: pink;
font-size: large;
}
/* o color:␣pink; C-[ */
I use e
and b
for horizontal navigation a lot. There might be other better ways but I consider this the most intuitive for me.
-- from this
require("config.def").setup()
-- to this
require("config.abc").setup()
require("config.def").setup()
-- yy P e e e b ce abc C-[
Text objects are awesome.
// from this
const xs = [0, 3, 6];
// to this
const xs = [0, 6, 12];
// ci[ 0,␣6,␣12 C-[
// from this
System.Collections.Generic.List
// to this
List
// d3f.
poggers.