Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
% VIM Quick Reference Card
% Copyright (c) 2009 Michael Goerz.
% TeX Format
% compile as 'pdftex vimqrc.tex'
% suppress all hyphenation
\pdfinfo {
/Title (Vim Quick Reference Card)
/Author (Michael Goerz)
/Subject (Vim Text Editor)
/Keywords (Movements, Insertion, Replace and Deletion, Insert Mode, Search and
Substitution, Formatting, Filtering, Visual Mode, Undoing and Repeating,
Registers, Copying, Patterns, Spell Checking, Marks, Motions and Tags, Multiple
Files and Buffers, Scrolling, Multi-Windowing, Ex Commands and Ranges,
Completion, Folding, Compiling)
% Font definitions
\def\title#1{\hfil{\bf #1}\hfil\par\vskip 2pt\hrule}
\def\cn#1{\hfill$\lfloor$ #1\par}
\def\section#1{\vskip 0.7cm {\it#1\/}\par}
% Characters definitions
% Three columns definitions
\parindent 0pt
\def\fullline{\hbox to\fullhsize}
\if L\lr
\else\if M\lr
% Card content
% Header
%\hrule\vskip 3pt
\vskip 0.5cm
\cm{:viusage }{Show a summary of all commands }
\cm{h l k j }{character left, right; line up, down }
\cm{b w }{word/token left, right }
\cm{ge e }{end of word/token left, right}
\cm{\lapos\ \rapos }{beginning of previous, next paragraph}
\cm{( ) }{beginning of previous, next sentence}
\cm{0 \^\ \$ }{beginning, first, last character of line}
\cm{$n$G $n$gg }{line $n$, default the last, first}
\cm{$n|$ }{column $n$ of current line}
\cm{\% }{match of next brace, bracket, comment, {\tt\#define}}
\cm{- + }{line up, down on first non-blank character}
\cm{B W }{space-separated word left, right}
\cm{gE E }{end of space-separated word left, right}
\cm{g0 gm }{beginning, middle of {\it screen\/} line}
\cm{g\^\ g\$ }{first, last character of {\it screen\/} line}
\cm{f$c$ F$c$ }{next, previous occurence of character $c$}
\cm{t$c$ T$c$ }{before next, previous occurence of $c$}
\section{Insertion \& Replace $\to$ insert mode}
\cm{i a }{insert before, after cursor}
\cm{I A }{insert at beginning, end of line}
\cm{gI }{insert text in first column}
\cm{o O }{open a new line below, above the current line}
\cm{r$c$ }{replace character under cursor with $c$}
\cm{gr$c$ }{like {\tt r}, but without affecting layout}
\cm{R }{replace characters starting at the cursor}
\cm{gR }{like {\tt R}, but without affecting layout}
\cm{c$m$ }{change text of movement command $m$}
\cm{cc\or S }{change current line}
\cm{C }{change to the end of line}
\cm{x X }{delete character under, before cursor}
\cm{d$m$ }{delete text of movement command $m$}
\cm{dd D }{delete current line, to the end of line}
\cm{J gJ }{join current line with next, without space}
\cm{:$r$d } {delete range $r$ lines}
\cm{:$r$d$x$ } {delete range $r$ lines into register $x$}
\section{Insert Mode}
\cm{\ctrl V$c$ \ctrl V$n$ }{insert char $c$ literally, decimal value $n$}
\cm{\ctrl V$n$ }{insert decimal value of character}
\cm{\ctrl A }{insert previously inserted text}
\cm{\ctrl @ }{same as {\tt\ctrl A} and stop insert $\to$ command mode}
\cm{\ctrl R$x$ \ctrl R\ctrl R$x$ }{insert content of register $x$, literally}
\cm{\ctrl N \ctrl P }{text completion before, after cursor}
\cm{\ctrl W }{delete word before cursor}
\cm{\ctrl U }{delete all inserted character in current line}
\cm{\ctrl D \ctrl T }{shift left, right one shift width}
\cm{\ctrl K$c_1$$c_2$\or $c_1$\kern-1pt\backspace$c_2$ }{enter digraph $\{c_1,c_2\}$}
\cm{\ctrl O$c$ }{execute $c$ in temporary command mode}
\cm{\ctrl X\ctrl E \ctrl X\ctrl Y }{scroll up, down}
\cm{\key{esc}\or \ctrl\lbracket}{abandon edition $\to$ command mode}
%\vskip 0.4cm
\section{Search \& Substitution}
\cm{/$s$\enter\ ?$s$\enter }{search forward, backward for $s$}
\cm{/$s$/$o$\enter\ ?$s$?$o$\enter }{search fwd, bwd for $s$ with offset $o$}
\cm{n\or /\enter }{repeat forward last search}
\cm{N\or ?\enter }{repeat backward last search}
\cm{\# * }{search backward, forward for word under cursor}
\cm{g\# g* }{same, but also find partial matches}
\cm{gd gD }{local, global definition of symbol under cursor}
\cm{:$r$s/$f$/$t$/$x$ } {substitute $f$ by $t$ in range $r$}
\cn{$x:$ {\tt g}---all occurrences, {\tt c}---confirm changes}
\cm{:$r$s $x$ } {repeat substitution with new $r$ \& $x$}
%\vskip 0.4cm
$m$ is movement; leave out for visual mode commands \\
\cm{gq$m$}{format $m$ ({\it formatprg})}
\cm{gqgq \or gqip}{format current paragraph}
\cm{$=m$}{reindent movement $m$ ({\it equalprg})}
\cm{:$r$ce $w$ } {center lines in range $r$ to width $w$}
\cm{:$r$le $i$ } {left align lines in range $r$ with indent $i$}
\cm{:$r$ri $w$ } {right align lines in range $r$ to width $w$}
\cm{!$m$$c$\enter }{filter lines of movement $m$ through command $c$}
\cm{$n$!!$c$\enter }{filter $n$ lines through command $c$}
\cm{:$r$!$c$ } {filter range $r$ lines through command $c$}
\cm{\tild }{switch case and advance cursor}
\cm{g\tild{$m$} gu$m$ gU$m$ }{switch case, lc, uc on movement $m$}
\cm{$<$$m$ $>$$m$ }{shift left, right text of movement $m$}
\cm{$n$$<$\kern-3pt$<$ $n$$>$\kern-3pt$>$ }{shift $n$ lines left, right}
\cm{\ctrl A \ctrl X}{increment/decrement number under cursor}
%\vskip 0.8cm
\section{Visual Mode \& Text Objects}
\cm{v V \ctrl V }{highlight characters, lines, block}
\cm{o }{exchange cursor pos with start of highlighting}
\cm{gv }{start highlighting on previous visual area}
\cm{aw as ap }{select a word, a sentence, a paragraph}
\cm{ab aB a] a$>$}{select a block ( ), {\tt\lapos} {\tt\rapos}, [~] $<$~$>$}
\cm{at}{select an html tag}
\cm{a" a' a`}{select a quotet string}
\cm{iw is ip ib iB i] i$>$ it i" i' i`}{select ``inner''}
\cm{$n\hskip -0.3em>$ $n\hskip -0.3em<$ $=$ }{indent/unindent $n$ levels, reindent}
\vskip -0.2cm
\section{Undoing, Repeating \& Registers}
\cm{u U }{undo last command, restore last changed line}
\cm{.\thinspace\thinspace\ctrl R }{repeat last changes, redo last undo}
\cm{$n$.\ }{repeat last changes with count replaced by $n$ }
\cm{q$c$ q$C$ }{record, append typed characters in register $c$}
\cm{q }{stop recording}
\cm{@$c$ }{execute the content of register $c$}
\cm{@@ }{repeat previous {\tt @} command}
\cm{:@$c$ } {execute register $c$ as an {\it Ex\/} command}
\vskip -0.2cm
\section{Copying (Yanking)}
\cm{"$x$ }{use register $x$ for next delete, yank, put}
\cm{:reg [$x$] } {show content registers/$x$ reg}
\cm{y$m$ }{yank the text of movement command $m$}
\cm{yy\or Y }{yank current line into register}
\cm{p P }{put register after, before cursor position}
\cm{\rbracket p \lbracket p }{like {\tt p}, {\tt P} with indent adjusted}
\cm{gp gP }{like {\tt p}, {\tt P} leaving cursor after new text}
\section{Patterns (differences to Perl) ~~ {\tt :help pattern}}
\cm{\bs$<$ \bs$>$ }{start, end of word}
\cm{\bs i \bs k \bs I \bs K }{an identifier, keyword; excl. digits}
\cm{\bs f \bs p \bs F \bs P }{a file name, printable char.; excl. digits}
\cm{\bs e \bs t \bs r \bs b }{\key{esc}, \key{tab}, \key{\enter}, \key{$\gets$}}
\cm{\bs = * \bs + }{match $0..1$, $0..\infty$, $1..\infty$ of preceding atoms}
\cm{\bs$\{n,m\}$ }{match $n$ to $m$ occurrences}
\cm{\bs$\{-\}$ }{non-greedy match}
\cm{\bs$|$ }{separate two branches ($\equiv$ {\it or\/})}
\cm{\bs( \bs) }{group patterns into an atom}
\cm{\bs \& \bs{}1 }{the whole matched pattern, $1^{st}$ {\tt()} group}
\cm{\bs u \bs l }{upper, lowercase character}
\cm{\bs c \bs C }{ignore, match case on next pattern}
\cm{\bs \%x }{match hex character}
\cm{\bs @= \bs @! }{\tt (?=pattern) (?!pattern)\rm}
\cm{\bs @$<$= \bs @$<$! }{\tt (?$<$=pattern) (?$<$!pattern)\rm}
\cm{\bs @$>$ }{\tt (?$>$pattern)\rm }
\cm{\bs\_\^{} \bs\_\$ }{start-of-line/end-of-line, anywhere in pattern}
\cm{\bs\_. }{any single char, including end-of-line}
\cm{\bs zs \bs ze }{set start/end of pattern}
\cm{\bs \%\^{} \bs\%\$ }{match start/end of file}
\cm{\bs\%{}V }{match inside visual area}
\cm{\bs\tt'\rm m }{match with position of mark m}
\cm{\bs\%(\bs) }{unnamed grouping}
\cm{\bs\_$[$ $]$ }{collection with end-of-line included}
\cm{\bs\%$[$ $]$ }{sequence of optionally matched atoms}
\cm{\bs{}v }{very magic: patterns almost like perl}
\vskip -0.2cm
\section{Spell Checking}
\cm{:set spell spelllang=de\_20 } {activate spellcheck}
\cm{$]$s }{next misspelled word}
\cm{zg zG }{add good word (to internal word list)}
\cm{zw zW }{mark bad word (to internal word list)}
\cm{z= }{suggest corrections}
\section{Marks, Motions, and Tags}
\cm{m$c$ }{mark current position with mark $c\in[a..Z]$}
\cm{`$c$ `$C$ }{go to mark $c$ in current, $C$ in any file}
\cm{`\/` `\/" }{go to position before jump, at last edit}
\cm{`[ `] }{go to start, end of previously operated text}
\cm{:marks } {print the active marks list}
\cm{:jumps } {print the jump list}
\cm{$n$\ctrl O }{go to $n^{th}$ older position in jump list}
\cm{$n$\ctrl I }{go to $n^{th}$ newer position in jump list}
\cm{\ctrl ] \ctrl T }{jump to the tag under cursor, return from tag}
\cm{:ts $t$ } {list matching tags and select one for jump}
\cm{:tj $t$ } {jump to tag or select one if multiple matches}
\cm{gf }{open file which filename is under cursor}
\cm{:tags } {print tag list}
\section{Multiple Files / Buffers (\enter)}
\cm{:tab ball }{show buffer tablist}
\cm{:buffers }{show list of buffers}
\cm{:buffer n }{switch to buffer n}
\cm{:badd f.txt }{load file into new buffer}
\cm{:bdelete n }{delete buffer n (also with filename)}
\cm{:bnext :bprev :bfirst :blast }{buffer movement}
\section{Scrolling \& Multi-Windowing}
\cm{\ctrl D \ctrl U \ctrl F \ctrl B}{scroll half / full page page down, up}
\cm{zt zz zb }{current line to top, center, bottom of win}
\cm{:[v]split \ctrl Ws \ctrl Wv} {split window (horiz., vert.)}
\cm{:vert help}{open help vertically}
\cm{\ctrl Wf \ctrl W]}{open file, tag in split}
\cm{:[v]new \ctrl W\ctrl n } {new empty window (horiz., vert.)}
\cm{:on \ctrl Wo} {make current win the only one}
\cm{\ctrl Wj \ctrl Wk \ctrl Wh \ctrl Wl }{move down, up, left, right to win}
\cm{\ctrl WJ \ctrl WK \ctrl WH \ctrl WL }{move win down, up, left, right}
\cm{\ctrl W$n$+ \ctrl W$n$- }{increase/decrease win size by $n$ lines}
\cm{\ctrl W$n>$ \ctrl W$n<$ }{increase/decrease window width}
\cm{\ctrl W$n$\_ \ctrl W$n$|}{set height/width (max if no $n$)}
\cm{\ctrl W=}{Make win size equal}
\cm{\ctrl Wr \ctrl Wx}{Rotate, exchange windows}
\cm{\ctrl Wc}{close window}
\vskip -0.2cm
\section{Misc Ex Commands (\enter) ~~ \tt{:help holy-grail}}
\cm{:e $f$ }{edit file $f$, reload current file if no $f$}
\cm{:$r$~w $f$ }{write range $r$ to file $f$ (current file if no $f$)}
\cm{:$r$~w$>$\kern-3pt$>$$f$ }{append range $r$ to file $f$}
\cm{:$r$~g[!]/$p$/$cmd$ }{ex $cmd$ on range $r$ [not] matching $p$}
\cm{:q :q! }{quit and confirm, quit and discard changes}
\cm{:wq\or :x\or ZZ }{write to current file and exit}
\cm{:r $f$ }{insert content of file $f$ below cursor}
\cm{:r!\ $c$ }{insert output of command $c$ below cursor}
\cm{:$r$c\ $a$ :$r$m\ $a$ }{copy, move range $r$ below line $a$}
\vskip -0.2cm
\section{Ex Ranges}
\cm{, ;\ }{separates two lines numbers, set to first line }
\cm{$n$ }{an absolute line number $n$}
\cm{.\thinspace\thinspace\thinspace\$ }{the current line, the last line in file}
\cm{\% * }{entire file, visual area}
\cm{'$t$ }{position of mark $t$}
\cm{/$p$/ ?$p$? }{the next, previous line where $p$ matches}
\cm{+$n$ -$n$ }{$+n$, $-n$ to the preceding line number}
\vskip -0.2cm
\cm{\ctrl{}X\ctrl{}L}{whole lines}
\cm{\ctrl{}X\ctrl{}N \ctrl{}X\ctrl{}I}{keywords in current file, plus included files}
\cm{\ctrl{}X\ctrl{}K \ctrl{}X\ctrl{}N}{keywords in dictionary, thesaurus}
\cm{\ctrl{}X\ctrl{}] \ctrl{}X\ctrl{}F \ctrl{}X\ctrl{}D}{tags, filenames, defs/macros}
\cm{\ctrl{}X\ctrl{}V}{vim command line}
\cm{\ctrl{}X\ctrl{}U \ctrl{}X\ctrl{}O}{user defined, omni- completion}
\cm{:set fdm=indent } {indent-foldmethod}
\cm{zf$m$ }{create fold of movement $m$}
\cm{:$r$fo }{create fold for range $r$}
\cm{zd zE }{delete fold at cursor, all in window}
\cm{zo zc zO zC }{open, close one fold; recursively}
\cm{[z ]z }{move to start, end of current open fold}
\cm{zj zk }{move down, up to start, end of next fold}
\cm{zm zM }{fold more, close all folds}
\cm{zr zR }{fold less, open all folds}
\cm{zn zN zi }{fold non, fold normal, invert folding}
\cm{:set foldcolumn=4 } {show foldcolumn}
\cm{:compiler $c$ }{set/show compiler plugins}
\cm{:make } {run {\tt makeprg}, jump to first error}
\cm{:cope } {navigate errors from make}
\cm{:cn :cp } {display the next, previous error}
\cm{:cl :cf } {list all errors, read errors from file}
\cm{:sh :!$c$ } {start shell, execute command $c$ in shell}
\cm{K }{run {\tt keywordprg} (man) on word under cursor}
\cm{\ctrl L }{redraw screen}
\cm{\ctrl G }{show cursor column, line, and character position}
\cm{:set cuc } {show cursor column visually}
\cm{ga }{show A{\smallrm SCII} value of character under cursor}
\cm{:mkview $[f]$ :loadview $[f]$ }{save/load configuration}
\cm{:set ff=dos } {convert file to dos eol format}
\cm{:e ++ff=unix } {reopen file in unix eol format}
\cm{:write ++enc=utf-8}{Write file in utf-8}
\cm{:set hlsearch } {highlight searches}
\cm{:$r$hardcopy > }{print range to ps file}
\cm{:set list }{show listchar characters (tabs etc.)}
% Footer
\vfill \hrule\smallskip
{\smallrm This card may be freely distributed under
the terms of the GNU general public licence ---
Copyright \copyright\ {\oldstyle 2010} by Michael Goerz.
{\smalltt}. Based on original by
Laurent Gr\'egoire ({\smalltt})}
% Ending
\if L\lr \else\null\vfill\eject\fi
\if L\lr \else\null\vfill\eject\fi