\documentclass{article}
% $Id: vi-back.tex,v 1.9 2004/09/28 18:19:11 dbindner Exp $
% Copyright 2002-2005 Donald Bindner
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
% 
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
% 
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


\usepackage{multicol}

\setlength{\textheight}{7.5 in}
\setlength{\textwidth}{10 in}
\setlength{\hoffset}{-2 in}
\setlength{\voffset}{-1 in}
\setlength{\footskip}{12 pt}
\setlength{\oddsidemargin}{1.5 in}
\setlength{\evensidemargin}{1.5 in}
\setlength{\topmargin}{.5 in}
\setlength{\headheight}{12 pt}
\setlength{\headsep}{0 in}

\setlength{\parindent}{0 in}

\ifx \pdfpagewidth \undefined
\else
 \pdfpagewidth=11in    % page width of PDF output
 \pdfpageheight=8.5in  % page height of PDF output
\fi

\newcommand{\ctrl}{C-}

\begin{document}
\thispagestyle{empty}
\fontsize{9}{10}\selectfont

\newcommand{\key}[2]{#1 \hfill \texttt{#2}\par}
\newcommand{\head}[1]{{\large\textbf{#1}}\\}

\begin{multicols}{3}
{\Large The Back Side --- Vim Extensions}

\vskip 15pt

\vbox{\head{Visual Mode}
Probably the most useful extension in Vim is visual mode.  It allows you to
highlight a region of text for the application of an editing or ``colon''
command.\par
\vskip 5pt
\key{highlight by character}{v}
\key{highlight by line}{V}
\key{highlight by column}{\ctrl V}
\key{re--select previous visual area}{gv}
}

\vskip 10pt

\vbox{\head{Windows}
Even on text consoles, Vim allows the editing environment to be divided
into separate windows which may contain the same or different files.
Commands that open a new window take an optional \textit{file} argument.\par
\vskip 5pt
\key{open new horizontal window}{:new}
\key{split window horizontally}{:split}
\key{split vertically}{:vsplit}
\key{close current window}{:close}
\key{close all but current window}{:only}
\key{cycle to next window}{\ctrl W w}
\key{cycle to previous window}{\ctrl W p}
\key{make windows equal height, width}{\ctrl W = , \ctrl W |}
\key{decrease, increase height one}{\ctrl W - , \ctrl W +}
\key{decrease, increase width one}{\ctrl W < , \ctrl W >}
}

\vskip 10pt

\vbox{\head{Objects}
In addition to the usual motions that are supported by Vi, Vim supports
several objects: word, sentence, paragraph, and block.  These are used with
editing commands (delete, change, and yank).  The advantage over
motions is that you do not have to be at one end of an object to use it.
For example \texttt{das} will delete a sentence from anywhere within it.\par
\vskip 5pt
\key{a word, a sentence, a paragraph}{aw, as, ap}
\key{same without white space (inner)}{iw, is, ip}
\key{blocks delimited by $[\,]$, (), \texttt{<>}, and $\{\}$}{a[, a(, a<, a$\{$}
\key{same without surrounding brackets}{i[, i(, i<, i$\{$}
}

\vskip 10pt

\vbox{\head{Extra motions}
\key{jump to beginning, end of $\{\,\}$ block}{[$\{$ , ]$\}$}
\key{same for parentheses}{[( , ])}
\key{same for / (C--style comments)}{[/ , ]/}
\key{previous end of word, space--delimited}{ge, gE}
}

\vskip 10pt

\vbox{\head{Extra markers}
Marks set with capital letters are ``global''; jumping to a global mark may
take you to a different file.  Several marks are remembered between
editing sessions:
\vskip 5pt
\key{position when file was last open}{'"}
\key{position where file was last edited}{'.}
\key{file and position of last Vim session}{'0}
}

\vskip 10pt

\vbox{\head{Other searching}
\key{incremental search}{:set (no)incsearch}
\key{highlight search}{:set (no)hlsearch}
\key{ignore case in search}{:set (no)ignorecase}
\key{find word under cursor fwd, back}{* , \#}
}

\vskip 10pt

\vbox{\head{Interface and colors}
\key{syntax coloring}{:syntax on}
\key{switch to graphical}{:gui}
\vskip 5pt
\key{show line numbers}{:set number}
\key{show commands in progress}{:set showcmd}
\key{show matching bracket}{:set showmatch}
\vskip 5pt
\key{autoindent}{:set ai}
\key{smartindent}{:set si}
\key{file format (dos, unix, mac)}{:set ff=...}
\key{good for editing tables}{:set virtualedit=all}
\key{edit option set}{:options}
}

\vskip 10pt

\vbox{\head{Insert mode editing}
There are some commands available while in insert mode:\par
\vskip 5pt
\key{copy from line above, below}{\ctrl Y , \ctrl E}
\key{complete from previous match}{\ctrl P}
\key{insert from (paste) register}{\ctrl R}
\key{insert digraph}{\ctrl K \textit{di}}
\key{execute single command}{\ctrl O \textit{command}}
}

\vskip 10pt

\vbox{\head{Folding}
To make working with a file more convenient, multiple lines may be
``folded'' together into a single highlighted line.  Use this to get long
sections out of the way while editing.\par
\vskip 5pt
\key{create, delete a fold}{zf, zd}
\key{open, (re--)close a fold}{zo, zc}
\key{remove outermost folds, more folds}{zr, zm}
\key{remove all, re--fold all folds}{zR, zM}
\key{disable, (re--)enable, toggle folds}{zn, zN, zi}
\key{save, load view (including folds)}{:mkview, :lo}
}

\vskip 10pt

\vbox{\head{Compiling and source code}
There are several commands for facilitating software development:
\vskip 5pt
\key{correct indentation of line}{==}
\key{increase the indent level}{>>}
\key{decrease the indent level}{<<}
\vskip 5pt
\key{run make and move cursor to first error}{:make}
\key{move to next, previous error}{:cnext, :cprev}
\key{move to first, last error}{:cfirst, :clast}
\key{view error or list of errors}{:cc, :clist}
\key{list lines with identifier under cursor}{[I}
}

\vskip 10pt

\vbox{\head{Using ctags}
You must first run ctags or etags on your file to use these features.\par
\vskip 5pt
\key{jump to function with tagname}{:tag \textit{tagname}}
\key{jump to tag under cursor}{\ctrl ]}
\key{previous tag}{\ctrl t}
}

\vskip 10pt

\vbox{\head{Other}
\key{reformat margins}{gq}
\key{make case upper, lower, toggle}{gU, gu, g\~\ }
\key{add subtract from number under cursor}{\ctrl A , \ctrl X}
\key{edit file under cursor}{gf}
\key{view man page under cursor}{K}
\key{print highlighted copy}{:hardcopy}
\key{list digraphs}{:digraphs}
\key{editable command history}{q:}
}

\end{multicols}

\vspace{\fill}
\copyright 2002-2005 Donald J.\ Bindner -- licensed under the terms of the GNU
General Public License 2.0 or later.
\end{document}

