The ABCs of vim
In a daze, I typed abcdefghijklmnopqrstuvwxyz
into Vim to see what would happen, and got bcdefghijklmnopqrstuvwxyz
. Well, that was boring. Anyway, it gave me the idea to write this short guide for what every letter of the alphabet represents/does in vim, along with a few of the commands I use on a (semi-)regular basis for each one. Enjoy!
A is for After
a
- enter Insert Mode after the highlighted character.A
- enter Insert Mode after the current line.
B is for Back
b
- move back one word.B
- move back one WORD.
C is for Change
cw
- delete the following word and enters Insert Mode to change it.ctG
- change all text ’till the nextG
.C
- change the remainder of the current line.
D is for Delete
diw
delete the inside of the current word.
dd
delete the current line.
D
delete the remainder of the current line.
E is for End
e
- Navigate to the end of the following word.E
- Navigate to the end of the following WORD.
F is for Find
fG
- Find the next occurrence ofG
on the current line.FG
- Find the previous occurrence ofG
on the current line.
G is for Go
12g
- Go to line 12 in the current file.gg
- Go to the top of the current file.G
- Go to the bottom of the current file.
H is for Left
h
- move the cursor left
I is for Insert or Inside
i
- enter Insert Mode.cip
- change inside the current paragraph.
J is for Jerk
J
- jerk the next line up, placing its contents at the end of the current line.j
- move the cursor down.
K is for Up
10k
- move the cursor up 10 times.
L is for Last
L
- jump to the last visible line in the window.l
- move the cursor right.
M is for Mark
m'
- set a mark that can be jumped back to using the command''
.
N is for Next
n
- Finds the next occurrence of the current search term (argument to/
or?
)N
- Finds the previous occurrence of the current search term (backwards next)
O is for Over
o
- begin a new line over (below) the current line.O
- begin a new line over (above) the current line.
P is for Put or Paragraph
p
- put the last yanked contents after the cursor.P
- put the last yanked contents before the cursor."mp
- put the contents of registerm
at the current location.dip
- delete inside the current paragraph.
Q is for … reQord? or Quit
qj
- record a macro to registerj
. Hittingq
again ends the macro. It can be executed later with the command@j
.:q
- quit vim
R is for Replace
rw
- replace the highlighted character withw
R
- Enter Replace Mode. Type to replace characters until finished. Press Esc to quit Replace Mode.
S is for Supplant or Surround*
s
- supplant the highlighted character (delete it and enter Insert Mode.)S
- supplant the current line.cs"(
- change surrounding quotation marks to parentheses.*ysw"
- surround the current word with parentheses.*dsw
- delete the surroundings of the current word.*
* Must have vim-surround
installed.
T is for ’Till
dt(
- Delete ’till the next open parenthesis.
(t
is just like f
, but stops at the character before the occurrence)
U is for Undo
u
- undo the last change.10u
- undo the last 10 changes.
V is for Visual
v
- enter Visual mode.V
- enter Visual Line mode.<CTRL>v
- enter Visual Block mode.
W is for Word or Write
daw
- delete around the highlighted word.:w
- write the current file to disk.
X is for eXtract
x
- extract (delete without mode change) the character under the cursor.X
- extract the character before the cursor.
Y is for Yank
3yw
- yank (insert into the unnamed register).the next 3 wordsyy
- yank the current line.Y
- yank the rest of the current line.
Z is for (looks like) Fold
zf}
- fold the rest of the current paragraph.za
- Toggle the fold (fold or unfold) underneath the cursor.