Vim Memo

Vim terminology

Standard wordVim term

Miscellaneous commands

Quit (w/o writing):qa[ll]! / :quita[ll]!
Write all and exit:wqa[ll] / :xa[ll]
Abort commandCTRL-C
Help:h[elp] <topic><F1>
Go to tag definitionCTRL-]
Go back:po[p]CTRL-T

Changing modes

Insert mode (before cursor)iI: at the beginning of line
Insert mode (after cursor)aA: at the end of line
Replace modeR
Visual modevV: select lines; CTRL-V: select blocks

Files and buffers

Edit (open) file:e[dit] <file>
Write file:w[rite]
Close file (w/o writing):q[uit]!ZQ
Write and close file:wq / :x[it] / :exi[t]ZZ
Edit next file:n[ext]
Edig the alternate fileCTRL-^
Change buffer:b[uffer] <buffer>
Next buffer:bn[ext]
List buffers:ls / :buffers / :files

Moving around

Left / Down / Up / Righth / j / k / l
Scroll upCTRL-U
Scroll downCTRL-D
To beginning of next wordwW: same with whitespace-boundaries
To beginning of this wordbB: same with whitespace-boundaries
To the end of this wordeE: same with whitespace-boundaries
To the end of last wordgegE: same with whitespace-boundaries
To beginning of line0^: ignoring whitespace characters
To end of line$
To char <c> in current linef + <c>F: backwards (;: next, ,: previous)
To char before <c> in current linet + <c>T: backwards (;: next, ,: previous)
Change side (in visual mode)o
Jump to matching parenthesis%
Jump to beginning of filegg
Jump to the <n>-th line<n> + G
Jump to the end of fileG
Jump to top/middle/bottom of the windowH / M / L
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
Jump to last change`.`^: to last insertion
Back from a jump``
  • Special Motions
    • in Visual mode, or as parameters for other commands (e.g. d,c,y)
    A wordiwiW: same with whitespace-boundaries
    A word (plus spaces)awaW: same with whitespace-boundaries
    Between quotations marks (excluding)i"similarly with ',`,),],},>,t (tag)
    Between quotations marks (including)a"similarly with ',`,),],},>,t (tag)


New file in new window (horizontal):newCTRL-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>
Change to "the other" windowCTRL-W [CTRL-]w
Change to the (left/bottom/top/right) windowCTRL-W h/j/k/l
Close window:clo[se]CTRL-W c
Close all other windows:on[ly]CTRL-W [CTRL-]o


Delete current charxX: backwards
Replace current char with <c>r <c>
Delete lineddD: only to the right from cursor
Yank lineyy / Y
Open line belowoO: open row above
Deleted + <movement>
Change (delete + insert mode)c + <movement>C: (= Da)
Substitute a chars (= cl)S: (= Di)
Yanky + <movement>
PutpP: before cursor
Select register for next d/y/p" + <register>(yank always uses 0, as well)
Show registers:reg[isters] / :di[splay]
  • transpose chars: xp
  • transpose lines: ddp
  • duplicate line: yyp


black hole_
primary clipboard*
current filename%
alternate filename#
last insertion.
last Ex command:
last search/

Search & replace

Search <string>/ <string>?: backwards
Search word under cursor*
Next matchnN: 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/
  • can have offsets, e.g. start/+1,/end-1
  • visual mode selections also specify ranges


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>

Date: 2016-07-06T12:34+0900

Author: Peter Salvi

Org version 7.9.3f with Emacs version 24

Validate XHTML 1.0