vim
vim notes
nav
0 | to line beginning |
$ | to line end |
^ | to first non-space character on the line |
g_ | to last non-space character on the line |
gg | to first line |
G | to last line |
g; | to last edit |
12G | to line 12 |
Ctrl + e | scroll one line down |
Ctrl + y | scroll one line up |
H | to viewport head |
M | to viewport middle |
L | to viewport bottom |
word nav
w | to next word’s beginning |
e | to next word’s end |
b | to previous word’s beginning |
ge | to previous word’s end |
substitution
command mode:
:s/meat/veggies/g | sub "meat" with "veggies" in a line |
:%s/meat/veggies/g | sub in all lines |
:16,18s/meat/veggies/g | sub in lines 16–18 |
search
/mieu | search forward for "mieu" |
?mieu | search backward for "mieu" |
/\cmieu | search for "mieu" and ignore cases |
/\<mieu\> | search for "mieu" exactly |
misc
commands
:w | save, write changes to file |
:update | save only if there are changes |
:x | exit |
:q | quit |
modes
normal
x | cut a character |
dd | cut a line |
daw | cut current word with spaces |
yy | copy line |
y$ | copy to line’s end |
yiw | copy current word sans spaces |
p | paste after |
P | paste before |
gp | paste after and move cursor after pasted text |
u | undo |
Ctrl + r | redo |
Ctrl + a | increase number (on cursor) |
Ctrl + x | decrease number (on cursor) |
insert
i | insert at cursor |
a | insert after cursor (append) |
I | insert at current line’s start |
A | insert at current line’s end |
o | insert new line below current line |
O | insert new line above current line |
s | delete character under cursor |
S | delete all text on line |
cw | delete to current word’s end |
C | delete from cursor to line’s end |
visual
v | highlight |
V | highlight line |
Ctrl + v | highlight block |
d | delete (cut) |
y | yank (copy) |
p | put (paste) |