\documentclass{slides}
\usepackage[landscape,pdftex]{geometry}
\parindent=0pt \parskip=0pt

%% ================================================================
\usepackage{ifthen}

%% ================================================================
\begin{document}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
INTRODUCTION TO VIM \\
\vspace{1.0in}
John Kerl \\
University of Arizona \\
Department of Mathematics \\
Software Interest Group \\
September 7, 2005
\end{center}
\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{Overview}
\end{center}

\begin{itemize}
\vspace{-0.25in} \item Why
\vspace{-0.25in} \item What
\vspace{-0.25in} \item How
\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{Why use a power editor such as vim or emacs?}
\end{center}

\begin{itemize}
\vspace{-0.40in} \item Notepad, gedit, et al. provide easy point-and-click use,
	with very low learning curve.  These are great tools, and they suffice for
	many people much of the time.
\vspace{-0.40in} \item Much of our time in math, sciences, and engineering
	(as well as many other fields!) is spent editing text files: C/C++ source
	code, Matlab .m files, .tex files (such as this one!), .html/.css/.php
	files, etc.
\vspace{-0.40in} \item If you don't enjoy these tasks, make it efficient
	so that you can spend more time doing what you want to do.
\vspace{-0.40in} \item If you do enjoy these tasks, make it efficient so
	that you can be more productive.
\vspace{-0.40in} \item A power editor can increase your productivity
	many times over.  For example, the more comfortable and efficient you
	are at creating \LaTeX files, the more likely you will be to create
	easy-to-read papers, slides, exams, vita, etc.  This benefits your career.
\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{What power editors do}
\end{center}

Features:

\begin{itemize}
\vspace{-0.50in} \item Commands can be executed using keystrokes, instead of
	or in addition to drop-down menus.  Keeps you from moving your hands
	back and forth between the mouse and keyboard.
\vspace{-0.50in} \item Customizable key binding, to abbreviate your most-used
	commands.
\vspace{-0.50in} \item Syntax highlighting.  Not just decoration --- helps
	detect typos early, keeping you from having to decipher cryptic error
	messages from \LaTeX.
\vspace{-0.50in} \item Macros and scripting to automate repetitive tasks.
\vspace{-0.50in} \item Ability to pipe part or all of a file out to an external
	program.
\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{What power editors do, continued}
\end{center}

\begin{itemize}
\vspace{-0.25in} \item Parenthesis matching.  Useful for many programming
	languages, but especially LISP!
\vspace{-0.25in} \item Tags files for C/C++ programs:
	\begin{itemize}
		\vspace{-0.25in} \item Run the ctags program.
		\vspace{-0.25in} \item Edit your C/C++ source code.
		\vspace{-0.25in} \item Push a key (control-$]$ in vim) to move from a
			function or variable to its definition.
		\vspace{-0.25in} \item Push another key (control-t in vim) to move back.
		\vspace{-0.25in} \item These may be nested --- there is a ``tag stack''.
		\vspace{-0.25in} \item This makes code archaeology much easier.
	\end{itemize}

\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{vi}
\end{center}

\begin{itemize}
\vspace{-0.25in} \item History: vi, short for visual editor, was
	written by Bill Joy in 1976.  It was one of the first full-screen editors
	(i.e. not a line editor).
\vspace{-0.25in} \item It was designed for use over a 300-baud modem, so
	it minimized keystrokes.  Slow modems are a thing of the past, but
	minimal number of keystrokes is still desirable.
\vspace{-0.25in} \item vi is present on all Unix-like systems.
\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{vim}
\end{center}

\begin{itemize}
\vspace{-0.25in} \item vim, short for vi improved, was written by Bram
	Moolenaar in the early 90s.
\vspace{-0.25in} \item vim does everything vi does,
	and much more:  multiple-level undo, multiple windows and buffers, macros,
	block operators, on-line help, syntax highlighting, mouse and GUI support,
	etc.
\vspace{-0.25in} \item Standard component of all major Linux distributions.
\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{How to use vim}
\end{center}

\begin{itemize}
\vspace{-0.25in} \item Fundamental concept:  vim is a \textbf{modal editor}.
\vspace{-0.25in} \item In most editors, including Emacs, the letter keys are
	always used for inserting text.  This means commands must be entered
	using physically awkward combinations of control, alt (meta), and/or
	letter keys --- or, mouse menus.
\vspace{-0.25in} \item In vim, you are either in \textbf{command mode} or
	\textbf{editing mode}.  E.g. the letter j is the same as down arrow
	when you are in command mode.
\vspace{-0.25in} \item Result:  you keep your hands on the keyboard and your
	eyes on the screen.  You accomplish more, in less time.
\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{Getting in and out}
\end{center}

\begin{itemize}
\vspace{-0.25in} \item vim \emph{(filename)} ---  Start editing
	\emph{(filename)} by typing the vim (or gvim) command at the command prompt.
\vspace{-0.25in} \item \textbf{:w} \emph{(new name)} --- save as.
\vspace{-0.25in} \item \textbf{:w!} \emph{(new name)} --- save as with
	replace.
\vspace{-0.25in} \item \textbf{:w} --- save.
\vspace{-0.25in} \item \textbf{:q} --- quit.
\vspace{-0.25in} \item \textbf{:wq} --- save and quit.
\vspace{-0.25in} \item \textbf{:q!} --- quit, discarding changes.
\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{Moving around}
\end{center}

\begin{itemize}
\vspace{-0.25in} \item \textbf{h}, \textbf{l}, \textbf{k}, \textbf{j}
	--- left, right, up, down arrow.  (You can use the mouse and/or arrow keys
	too.)
\vspace{-0.25in} \item \textbf{control-b}, \textbf{control-f} --- page up/down.
	(You can also use the PageUp and PageDown keys on the keyboard.)
\vspace{-0.25in} \item \textbf{0, \$} --- move to start/end of line.
\vspace{-0.25in} \item \textbf{b, w} --- move backward/forward one word.
\vspace{-0.25in} \item \textbf{\{}, \textbf{\}} --- move up/down a paragraph.
\vspace{-0.25in} \item \textbf{\%} --- Move to matching bracket, if any.
	Works for $()$, $[]$, $\{\}$.
\vspace{-0.25in} \item Etc.
\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{Getting into and out of editing mode}
\end{center}

\begin{itemize}
\vspace{-0.25in} \item \textbf{i} ---  Insert at the current position.
\vspace{-0.25in} \item \textbf{I} ---  Insert at the start of the line.
\vspace{-0.25in} \item \textbf{A} ---  Insert at the end of the line.
\vspace{-0.25in} \item \textbf{o} ---  Insert below the current line.
\vspace{-0.25in} \item \textbf{O} ---  Insert above the current line.
\vspace{-0.25in} \item \textbf{cw} ---  Change current word.
\\
\vspace{-0.25in} \item \textbf{ESC} ---  Out of editing mode.
\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{More commands}
\end{center}

\begin{itemize}
\vspace{-0.50in} \item \textbf{x, X} ---  Delete current/previous character.
\vspace{-0.50in} \item \textbf{r} \emph{(key)} ---  Replace current character
\vspace{-0.50in} \item \textbf{$\sim$} --- invert case of current character.
\vspace{-0.50in} \item \textbf{u} --- undo.
\vspace{-0.50in} \item \textbf{control-r} --- redo.
\vspace{-0.50in} \item \textbf{/} \emph{(pattern)}--- Forward search.
\vspace{-0.50in} \item \textbf{?} \emph{(pattern)}--- Reverse search.
\vspace{-0.50in} \item \textbf{n}, \textbf{N} --- Next/previous match.
\vspace{-0.50in} \item \textbf{:\%s/old word/new word/g} --- Global search
	and replace.
\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{Copying and pasting}
\end{center}

\begin{itemize}
\vspace{-0.50in} \item \textbf{yy} ---  Copy (yank) current line.
\vspace{-0.50in} \item \textbf{3yy} ---  Copy current line and the next two.
\vspace{-0.50in} \item \textbf{3y\}} ---  Copy the next three paragraphs.
\vspace{-0.50in} \item \textbf{dd} ---  Cut (delete) current line.
\vspace{-0.50in} \item \textbf{3dd} ---  Cut current line and the
	next two.
\vspace{-0.50in} \item \textbf{3d\}} ---  Cut the next three paragraphs.
\vspace{-0.50in} \item \textbf{yw} ---  Copy current word.
\vspace{-0.50in} \item \textbf{dw} ---  Cut current word.
\vspace{-0.50in} \item In general, \textbf{y} or \textbf{d} followed by
	any cursor-motion command.  For example, \textbf{d\$}.
\vspace{-0.50in} \item \textbf{p} --- Paste after.
\vspace{-0.50in} \item \textbf{P} --- Paste before.
\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{Learning curve}
\end{center}

I was once a die-hard Emacs user, but found myself at a company where vi was on
all workstations, but Emacs was not.

Learning vi, I found that I did not try to memorize all possible commands.
Rather, I learned the most useful ones.  Later, after I became accustomed to
them, I learned some more commands as a way of saving keystrokes.

Different people have different crossover points for productivity vs.  amount
of things to memorize.  If you are learning vi or Emacs, I would suggest the
approach I used:  memorize what you need.  \textbf{Memorize more when you need
it.} Like playing the piano or learning to type by touch, your fingers will
learn what they use.

Also, \textbf{gvim} has a nice GUI.  If you wish, you can use familiar
point-and-click commands, gradually replacing them with more efficient
keystrokes as meets your needs.

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{.vimrc file}
\end{center}

The $\sim$/.vimrc file contains any particular settings you prefer.  Some of
these look messy, but you only type them in once and forget about the details.
Example lines:

\begin{itemize}
\vspace{-0.50in} \item \textbf{set vb t\_vb=} --- turn beep off.
\vspace{-0.50in} \item \textbf{set ts=4} --- set tabstop to 4.
\vspace{-0.50in} \item \textbf{syntax on} --- enable syntax highlighting.
\vspace{-0.50in} \item \textbf{map ; :} --- Do :wq, etc. without needing
	to hold down the shift key.
\vspace{-0.50in} \item \textbf{map - :.=\^{}M} --- Show current line number.
	(Note:  To enter the last character into your .vimrc file, type control-v
	followed by control-m.)
\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{.vimrc file, continued}
\end{center}

\begin{itemize}

\vspace{-0.50in} \item \textbf{map $\setminus$t O\%\% \emph{control-v
	ESC}64A-\emph{control-v ESC}} --- Insert a commented out line of dashes
	such as the following:

	\%\% ---------------------------------------------

	Helps make your .tex files easier to navigate through.

\vspace{-0.50in} \item \textbf{map $\setminus$w :w\^{}M:!latex \%\^{}M} ---
	Save current file and run it through latex, using just two keystrokes.

	Tip:  Leave ``xdvi filename.dvi \&'' running, then alt-tab to bring xdvi
	forward and back.  The xdvi program automatically reloads the .dvi every
	time it is foregrounded.  This enables rapid, iterative development of
	.tex files.  Then, pdflatex when you are ready to print.

\end{itemize}

\end{slide}

%% ----------------------------------------------------------------
\begin{slide}
\begin{center}
\textbf{Resources}
\end{center}

\begin{itemize}
\vspace{-0.25in} \item Type \textbf{vimtutor} at the command prompt.  The
	tutorial takes about half an hour.

\vspace{-0.25in} \item The file you are reading is at

	http://math.arizona.edu/$\sim$kerl/doc/vimswig/vimswig.pdf

	It was written in \LaTeX using vim:

	http://math.arizona.edu/$\sim$kerl/doc/vimswig/vimswig.tex

	It was typset using the command ``pdflatex vimswig.tex''.

\vspace{-0.25in} \item http://math.arizona.edu/$\sim$swig
\vspace{-0.25in} \item http://www.vim.org for on-line documentation and FAQ.
\vspace{-0.25in} \item Fly like the wind!
\end{itemize}

\end{slide}

\end{document}
