Vim Memo (summarizing the Getting Started part of the User's Manual)

Vim terminology

Standard word Vim term
save write
cut delete
copy yank
paste put
overwrite replace

Miscellaneous commands

Quit (w/o writing) :qa[ll]! / :quita[ll]!  
Write all and exit :wqa[ll] / :xa[ll]  
Abort command   CTRL-C
Undo :u[ndo] u
Redo :red[o] CTRL-R
Help :h[elp] <topic> <F1>
Go to tag definition   CTRL-]
Go back :po[p] CTRL-T / CTRL-O
Set an on/off option :set [no]<option> :set <option>? : current value
Set an option :set <option>=<value>  
List of options :options  
Syntax highlighting :syntax on/off :colorscheme : various schemes
Temporary Normal mode   CTRL-O (in Insert mode)

Changing modes

Insert mode (before cursor) i I: at the beginning of line
Insert mode (after cursor) a A: at the end of line
Replace mode R  
Visual mode v V: select lines; CTRL-V: select blocks

Files and buffers

Edit (open) file :e[dit] <file>  
Write file :w[rite] :w[rite] >> <file> : append to file
Close file (w/o writing) :q[uit]! ZQ
Write and close file :wq / :x[it] / :exi[t] ZZ
Save as :saveas <filename>  
Edit next file :n[ext] :wn[ext] : write and edit next file
Edit previous file :prev[ious] :wp[revious] : write and edit prev file
Edig the alternate file CTRL-^  
Change buffer :b[uffer] <buffer>  
Next buffer :bn[ext]  
List buffers :ls / :buffers / :files  

Moving around

Left / Down / Up / Right h / j / k / l  
Scroll forward (down) one page CTRL-F CTRL-D: half page; CTRL-E: one line
Scroll backward (up) one page CTRL-B CTRL-U: half page; CTRL-Y: one line
To beginning of next word w W: same with whitespace-boundaries
To beginning of this word b B: same with whitespace-boundaries
To the end of this word e E: same with whitespace-boundaries
To the end of last word ge gE: same with whitespace-boundaries
To beginning of line 0 ^: ignoring whitespace characters
To end of line $  
To char <c> in current line f + <c> F: backwards (;: next, ,: previous)
To char before <c> in current line t + <c> T: backwards (;: next, ,: previous)
Change side (in visual mode) o  
Jump to matching parenthesis %  
Jump to beginning of file gg  
Jump to the <n>-th line <n> + G  
Jump to the end of file G  
Jump to top/middle/bottom of the window H / M / L  
Show current line at top/middle/bottom zt / zz / zb  
Set a mark to the letter <c> m + <c> use uppercase letters for global marks
Jump to a mark at letter <c> ` + <c> ' + <c>: the beginning of that line
Show all marks :marks :marks <cde> : show only marks c,d,e
Jump to last change `. `^: to last insertion
Back from a jump ``  


New file in new window (horizontal) :new CTRL-W [CTRL-]n
New file in new window (vertical) :vne[w]  
Split window (horizontal) :sp[lit] CTRL-W [CTRL-]s
Split window (vertical) :vs[plit] CTRL-W [CTRL-]v
Edit file in new window (horizontal) :new <file> / :sp[lit] <file>  
Edit file in new window (vertical) :vne[w] <file> / :vs[plit] <file>  
Enlarge/shrink window vertically by N lines :res[ize] +N / :res[ize] -N [N] CTRL-W +/-
Enlarge/shrink window horizontally by N lines   [N] CTRL-W >/<
Resize window to full (or N) width :vertical :res[ize] [N] [N] CTRL-W |
Make all windows equal in size   CTRL-W =
Change to "the other" window   CTRL-W [CTRL-]w
Change to the (left/bottom/top/right) window   CTRL-W h/j/k/l
Move window to the (l/b/t/r) and maximimze   CTRL-W H/J/K/L
Close window :clo[se] CTRL-W c
Close all other windows :on[ly] CTRL-W [CTRL-]o


Edit file in new tab :tabe[dit] <file> / :tabnew <file>  
Edit same buffer in new tab :tab split  
Close current tab :tabc[lose]  
Close all other tabs :tab[only]  
Go to next tab :tabn[ext] gt
Go to previous tab :tabp[revious] / :tabN[ext] gT
Go to first tab :tabr[ewind] / :tabfir[st]  
Go to last tab :tabl[ast]  
Move tab N spaces :tabm[ove] +N / :tabm[ove] -N  
Run command in new tab :tab <command>  


Delete d + <movement>  
Delete line dd D: just right from cursor (= d$)
Change (delete + insert mode) c + <movement> C: (= Da)
Change line cc C: just right from cursor (= c$)
Delete current char x (= dl) X: backwards (= dh)
Substitute a char s (= cl) S: (= cc)
Replace current char with <c> r <c>  
Open line below o O: open row above
Yank y + <movement>  
Yank line yy / Y  
Put p P: before cursor
Select register for next d/y/p " + <register> (yank always uses 0, as well)
Show registers :reg[isters] / :di[splay]  
Change case g~ + <movement> ~: on one char & forward
Change to lowercase gu + <movement> gU + <movement>: uppercase
  • transpose chars: xp
  • transpose lines: ddp
  • duplicate line: yyp


default "
named a-z
named (appending) A-Z
last yank 0
last small delete -
recent large deletes 1-9
black hole _
clipboard +
primary clipboard *
expression =
current filename %
alternate filename #
last insertion .
last Ex command :
last search /

Search & replace

Search <string> / <string> ?: backwards
Search word under cursor *  
Next match n N: previous
Substitute :[<range>]s[ubstitute]/[<old>]/<new>[/<flags>] &: repeat (no flags)
  • <range> is the current line by default
  • <old> is the last search by default
  • flags: g (global), c (confirm), n (only count), & (same flags as before)
  • confirm mode: y/n (yes/no), q (quit), l (yes + quit), a (all); C-e/C-y (scroll up/down)


  • % means the whole file
  • a,b for lines a-b (. is the current line, 0 the zeroth, 1 the first, $ the last)
  • these can be regexps, e.g. start,/end/, or marks, e.g. 't,'b
  • can have offsets, e.g. start/+1,/end-1
  • visual mode selections also specify ranges (o: changes active end [O: other corner for blocks])


Record macro in <register> q + <register> [stop: q, use uppercase register to append]
Play macro in <register> @ + <register> [after that: @@]
Repeat last command .
Repeat <command> <n> times <n> + <command>
Repeat last Ex command @: [after that: @@]
Execute commands for range :[<range>] normal <commands>
Execute commands for matches :[<range>] global[!] <pattern> <commands>
Do for all buffers/windows :bufdo / :windo

Author: Peter Salvi

Created: 2021-02-14 Sun 16:51