|
Key
|
Action
|
i |
insert at cursor
|
I |
insert at the beginning of the line
|
a |
append after the cursor
|
A |
append at the end of the line
|
o |
open blank line below current line (no need to press return)
|
O |
open blank line above current line
|
ESC |
to exit insert mode (and return to normal mode)
|
Bi - insert at the start of the current wordea - append at the end of the current word Wi - insert at the start of next wordjI - insert at the start of next linejA - append at the end of next line
|
Key
|
Action
|
: |
enter command mode
|
Enter |
to action command
|
Esc x2 |
to exit command mode (and return to normal mode)
|
Enter key.
|
Key
|
Action
|
v |
enter visual mode
|
V |
enter visual-line mode
|
Ctrl-v |
enter visual-block mode
|
Esc x2 |
to exit visual mode (and return to normal mode)
|
dyI, <text,whitespace>, Esc, Escd
|
Key
|
Action
|
h |
move left (also left cursor)
|
j |
move down (also down cursor)
|
k |
move up (also up cursor)
|
l |
move right (also right cursor)
|
w |
jump forward to start of words (punctuation considered words)
|
W |
jump forward to start of words (spaces separate words)
|
e |
jump forward to end of words (punctuation considered words)
|
E |
jump forward to end of words (spaces separate words)
|
b |
jump backward to start of words (punctuation considered words)
|
B |
jump backward to start of words (spaces separate words)
|
0 |
jump to start of line (zero)
|
^ |
jump to first non-blank character of line
|
$ |
jump to end of line
|
G |
go to end of file
|
gg |
go to start of file
|
H |
move to top of screen (no screen movement)
|
M |
move to middle of screen (no screen movement)
|
L |
move to bottom of screen (no screen movement)
|
|
Key
|
Action
|
x |
delete character from right
|
X |
delete character to left
|
r |
replace a single character (does not use insert mode)
|
R |
replace multiple characters
|
|
change c+option
|
start change command (will enter Insert mode)
|
cw |
change to the end of word
|
cc |
change an entire line
|
c$ or C |
change to the end of line
|
cG |
change to end of file
|
|
delete d+option
|
start delete command (will stay in Normal mode)
|
dw |
delete word
|
dd |
delete entire line
|
d$ or D |
delete to the end of the line
|
dG |
delete to the end of the file
|
s |
delete character at cursor and substitute text (enters Insert mode)
|
S |
delete line at cursor and substitute text (same as cc)
|
xp |
transpose two letters (technically a combo to delete and paste)
|
u |
undo
|
Crtl-r |
redo
|
. |
repeat last command
|
J |
join current line with line below
|
dgg - delete to beginning for filec5w - change 5 words4dj - delete current and 4 other lines
|
Key
|
Action
|
|
delete
|
delete, i.e. cut (see previous)
|
|
yank (y+option)
|
yank, i.e. copy
|
yw |
yank word
|
yy |
yank line
|
2yy |
yank 2 lines
|
yj |
yank current and next line
|
|
put (p+option)
|
put, i.e. paste
|
p |
put clipboard contents after cursor
|
P |
put clipboard contents before cursor
|
2p |
paste 2 copies
|
|
Key
|
Action
|
/pattern |
search for pattern forward from cursor
|
?pattern |
search for pattern backward from cursor
|
n |
repeat search in same direction
|
N |
repeat search in opposite direction
|
:%s/old/new/g |
replace all old with new throughout file
|
:%s/old/new/gc |
replace all old with new throughout file with confirmations
|
:1,.%s/old/new/g |
search from start of file to current cursor position, replace all old with new
|
:.,$%s/old/new/g |
search from current cursor position to end of file, replace all old with new
|
|
Key
|
Action
|
:w |
write (save) the file, but don't exit
|
:w file |
write to new file
|
:1,5w file |
write lines 1-5 to new file
|
:wq or ZZ |
write (save) and quit
|
:q |
quit (fails if anything has changed)
|
:q! |
quit and discard changes
|
:r file |
read in file to current cursor position
|
:r !head -n5 file |
read in the first 5 lines of file to current cursor position
|
:e file |
edit file in new buffer
|
:sp file |
edit file in new buffer and split window
|
ctrl-ww |
switch between windows
|
!! command |
perform shell command, output will overwrite current line
|
:marks |
list of marks - includes mark name, line, column and text
|
ma |
set current position for mark 'a'
|
'a |
jump to position of mark 'a'
|
`a |
jump start of line of mark 'a'
|
y'a |
yank from current position to mark 'a'
|
:. |
perform action on current line
|
:1 |
perform action on line 1
|
:1,5 |
perform action on lines 1-5
|
:$ |
perform action on last line
|
:% |
perform action on all lines
|
:5,$ |
perform action on lines 5 to last
|
:.,$ |
perform action on current to last line
|
:.+1,$ |
perform action on line below current to last
|
:.+1,.+5 |
perform action on line below to 5 lines below current line
|
:'a,'b |
peform action from mark
a to mark b |
:1,5d - delete lines 1-5:5,.y - yank lines 5 to current:.,$s/old/new/g - replace old with new from current line to end of file'a,'by - yank from 'a' to 'b'
:set number |
display line numbers
|
:set number! or:set nonumber |
turn off line numbers
|
:colorscheme <colorscheme> |
change colorscheme
|
:version |
show version and other information
|
:set list |
show hidden characters
|
:set nolist |
do not show hidden characters
|
Ctrl-V, cursor highlight, I, #, Esc, Esc |
multi-line comment
|
Ctrl-V, cursor highlight, x |
delete multi-line comment
|
:nohl |
remove search highlight
|
:%s/^M//g |
replace DOS carriage returns (if
dos2unix is not installed) |
:nohl is shorthand for :nohlsearch
/etc/vimrc but setting personal defaults is preferred./usr/share/vim/vimXX/colors/.vimrc/.vim/colors~/.vimrccolorscheme <colorscheme>Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.