h
move leftj
move downk
move upl
move rightw
jump by start of words (punctuation considered words)W
jump by words (spaces separate words)e
jump to end of words (punctuation considered words)E
jump to end of words (no punctuation)b
jump backward by words (punctuation considered words)B
jump backward by words (no punctuation)0
move to start of line^
move to first non-blank character of line$
move to end of current lineline number
G
go to line numberG
move cursor to last line of documentM
move cursor to middle of documentgg
move cursor to first line of documentf
char
move cursor up to next instance of charF
char
move cursor up to previous instance of chart
char
move cursor to just before next instance of charT
char
move cursor to just before previous instance of char(
jumps to the previous sentence)
jumps to the next sentence{
jumps to the previous paragraph}
jumps to the next paragraph[[
jumps to the previous section]]
jumps to the next section[]
jump to the end of the previous section][
jump to the end of the next sectionH
jump to the last line on screenL
jump to the first line on screen<Ctrl> + d
move down half page<Ctrl> + u
move up half page<Ctrl> + f
move down whole page (same as Page Down)<Ctrl> + b
move up whole page (same as Page Up)
m
x
set mark xdelmarks
x
delete mark xdelm
x
delete mark x]'
jump to next line with a lowercase mark['
jump to previous line with a lowercase mark- `]`` jump to next lowercase mark
- `[`` jump to previous lowercase mark
- `5[`` jump back 5 lowercase marks
Vim has some special marks which it sets automatically. Here are some of the most useful:
\
.` jump to position where last change occurred in current buffer\
"` jump to position where last exited current buffer\
0` jump to position in last file edited (when exited Vim)\
1like
0 but the previous file (also `2 etc)''
jump back (to line in current buffer where jumped from)\
`` jump back (to position in current buffer where jumped from)\
[` jump to beginning of previously changed or yanked text\
]` jump to end of previously changed or yanked text\
<` jump to beginning end of last visual selection\
<` jump to end of last visual selection
i
start insert mode at cursorI
insert at the beginning of the linea
append after the cursorA
append at the end of the lineo
begin a new line below the cursorO
begin a new line above the cursorea
append at end of word<Ctrl> + h
delete previous character without leaving insert mode<Ctrl> + w
delete previous word without leaving insert mode<Ctrl> + u
delete line to left of cursor without leaving insert mode<Ctrl> + O
enter normal mode for next command<Esc>
exit insert mode
r
replace a single characterR
overwrite modeJ
join line below to the current onecc
change (replace) an entire linecw
change (replace) to the end of wordc$
change (replace) to the end of lineC
change (replace) to the end of lines
delete character at cursor and subsitute textS
delete entire line and substitute text (same as cc)xp
transpose two letters (cut and paste)guu
change current line to lowercasegUU
change current line to uppercaseg~~
invert case of current lineguw
change until end of current word to lowercaseguaw
change all of current word to lowercasegUw
change until end of current word to uppercasegUaw
change all of current word to uppercasegu
motion make all words in motion lowercasegU
motion make all words in motion uppercaseu
undo<Ctrl> + r
redo.
repeat last command (whole document);
repeat last command (on this line)<Ctrl> + t
indent current line (insert mode)<Ctrl> + d
unindent current line (insert mode)==
autoindent current line
v
start visual mode, mark lines, then do command (such as y-yank)V
start linewise visual mode<Ctrl> + v
start visual block modeo
move to other end of marked areaO
move to other corner of blockaw
mark a wordab
a () block (with braces)aB
a {} block (with brackets)ib
inner () blockiB
inner {} block<Esc>
exit visual mode
>
indent<
unindenty
yank (copy) marked textd
delete marked textU
convert selected text to uppercaseu
convert selected text to lowercase~
switch case of selected=
autoindent selection
yy
copy entire lineY
copy entire line2yy
copy 2 linesyw
copy wordy$
copy to end of linep
paste after cursorP
paste before cursordd
delete (cut) a linedw
delete (cut) the current worddaw
delete (cut) the current word (from any position in the word)x
delete (cut) current character:r
filename
insert the contents of filename below the cursor:r
command
execute command and insert its output below the cursor<Ctrl> + y
(when in insert mode) copy/paste character from line above
q
char <commands>
q
store commands in buffer char@
char
repeat commands stored in buffer char@@
repeat commands stored in the last used buffer (called buy@
char
)
/
pattern
search for pattern?
pattern
search backward for pattern*
search for word under cursorg*
search for partial word under cursor<Ctrl> + o
go forward through jump locations for word under cursor<Ctrl> + i
go backward through jump locations for word under cursor[I
show lines containing word under cursorn
move to next search instanceN
move to previous search instance:%s/old/new/g
replace all old with new throughout file:%s/old/new/gc
replace all old with new throughout file with confirmations
:e
filename Edit a file in a new buffer:bnext
(or :bn) go to next buffer:bprev
(of :bp) go to previous buffer:bd
delete a buffer (close a file):sp
filename
open filename in a new buffer and split window (horizontally):vsplit
filename
open filename in a new buffer and split window (vertically)<Ctrl> + ws
split windows<Ctrl> + ww
switch between windows<Ctrl> + wq
quit a window<Ctrl> + wv
split windows verticallygf
go to file under cursor<Ctrl> + o
jump backward one buffer<Ctrl> + i
jump forward one buffer<Ctrl> + ^
jump to the alternate (last edited) buffer
zz
translate screen so current line is at centerzt
translate screen so current line is at topzb
translate screen so current line is at bottom<Ctrl> + y
translate screen up one line (without moving cursor)<Ctrl> + e
translate screen down one line (without moving cursor)
:w
write (save) the file, but don't exit:q
quit (fails if anything has changed):wq
write (save) and quit:q!
quit and throw away changesZZ
same as:wq
ZQ
same as:q!
<Shift> + K
suspends vim and opens man page for the command under the cursor<Ctrl> + g
shows filename, status, # of lines, and percentage of way through bufferg + <Ctrl> + g
shows column, line, word, and byte information1 + <Ctrl> + g
shows full path filename, status, # of lines, and percentage of way through buffer<Ctrl> + s
stops (freezes) VIM<Ctrl> + q
resumes (unfreezes) VIM:%s/
pattern
//gn
count number of matches of pattern:%s/
pattern
//n
count number of lines that contain a match of pattern
:set ignorecase
case insensitive search:set smartcase
case insensitive search, unless something in search term is capital:set hlsearch/nohlsearch
highlight all search terms in document