vim tips and tricks

indenting

Some variables you might want to set:

 :set tabstop=8     - tabs are at proper location
 :set expandtab     - don't use actual tab character (ctrl-v)
 :set shiftwidth=4  - indenting is 4 spaces
 :set autoindent    - turns it on
 :set smartindent   - does the right thing (mostly) in programs
 :set cindent       - stricter rules for C programs

I like having auto on, but smart does funny things based on keywords.

To indent the current line, or a visual block:

ctrl-t, ctrl-d  - indent current line forward, backwards 
                  (insert mode)
visual > or <   - indent block by sw (repeat with . )

To stop indenting when pasting with the mouse, add this to your .vimrc:

:set pastetoggle=<f5>

then try hitting the F5 key while in insert mode (or just :set paste).