## things you might want on the fly ##

Wrap text (at whole words) at 79 cols:
:set tw=79
(79 is better than 80 for 80-col terminals, because it avoids having words
that end right at the terminal margin)

To wrap some existing lines:
1. visually select them
2. gq

To unwrap a single existing paragraph:
1. cursor into it
2. vipJ

To unwrap some existing paragraphs:
1. set tw to some very large value, e.g. ":set tw=99999999"
2. visually select them
3. gq
(you can also try ":%norm vipJ" to unwrap a whole document, but often this is
too aggressive)

Quickly set tab display width to 40 cols:
:set ts=40

Tell vim that a particular file needs a tab width setting of 46:
Put a line like this at the top of the file:
# vim: set ts=46 :

Expand tabs to spaces:
:set expandtab
(useful when making numbered lists in markdown, where subsequent paragraphs of
the same list item need to be indented by four spaces [or a tab, but that's
not a good idea if the leading paragraph was using spaces])

Format numbered list paragraphs beginning with, e.g., "1. ":
:set fo+=n

allow lines beginning with '#' to be indented:
:set nosmartindent
(probably want to "set smartindent" again soon after)

disable all auto-indenting and stuff, so that you can paste a block of
already-formatted text from elsewhere:
:set paste
(turn off again with "set nopaste")


## autocomplete ##

When typing a word that exists somewhere else in the file, start typing it and
then hit ctrl+n to show possible completions. (ctrl+p goes backwards in the
list.) to accept a match, just keep typing as if you'd typed the whole word
yourself; to cancel a match, ctrl+p back to the "empty" entry at the beginning
of the match list.


## visual selection ##

v: start selecting from cursor (use movement or searching to set end of
	selection)
V: start selecting whole lines
ctrl+v: block selection mode (useful note: text copied in block mode will be
	pasted in block mode, with necessary preceding spaces auto-inserted
	regardless of preceding line length)
ctrl+q: block selection mode when using a GUI where ctrl+v is paste


## useful movement ##

gg: top of file
G: bottom of file
34G or 34gg: go to line 34
ctrl+g: show total line count and current position as a percentage
ctrl+o: go back to previous ("old") position in the file
ctrl+i: go to more recent position
n: next search result
N: previous search result
*: while on a word, find next occurrence
#: while on a word, find previous occurrence
gD: go to first occurrence of word under cursor (probably -- actually this is
	"go to global declaration" and meant for things like C files, but usually
	works in plain text too)
ggn: go to first match of current search pattern (can confirm result of gD)
zz: scroll so current line is in the middle
zt: scroll so current line is at the top
zb: scroll so current line is at the bottom
ctrl+e: scroll down one line, leaving cursor where it is
ctrl+y: scroll up one line, leaving cursor where it is
^: first non-whitespace char on line (smart beginning of line)
0: actual beginning of line
$: end of line
w: forward one word
b: backward one word


## things you probably want in vimrc ##

allow backspace key to behave as expected (allow backspacing over existing
indent spaces, freshly inserted auto-indents, and back onto previous lines):
:set backspace=start,indent,eol
(note: this is now a default; should no longer be necessary)

don't auto-indent after lines beginning with 'for', 'do', 'while', etc.
:set cinwords=

Don't put two spaces after the period, if joining a to a line that ended with one:
:set nojoinspaces