It's vim!

Typical .vimrc

Here's what a typical .vimrc looks like for me:

if has('syntax') && (&t_Co > 2)
    syntax on

set history=50
set wildmode=list:longest,full
set showmode
set showcmd
set smartcase
set shiftwidth=4
set tabstop=4
set shiftround
set expandtab
set autoindent

autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except, finally,def,class


Search and replace globally:



I often want to pull a particular gnarly line or two from another file; here's the command I use to grab three lines of context around 'phrase':

:r!grep -A 3 'phrase' ../otherfile.txt

Pasting a lot of text with insert mode if very slow because vim redraws the terminal for every single character entered (as you would want if you were actually typing. To paste in the contents of the X11 clipboard you want to use:


(aka quote, star, uppercase-P) in regular mode. This also solves the autotabbing problem without ":set paste"! You need to have "+xterm_clipboard" in your vim --version output for this to work; the vim-gtk package on Debian/Ubuntu seems to have this flag compiled in, while vim-tiny does not.

Sometimes you really need tab characters instead of space indendation (eg, when editing Makefiles). To use tabs when editing a file use:

   :set noexpandtab

If you accidently opened a file you can't write to, you can write out as root using:

:w !sudo tee %

Search for trailing whitespace, or just strip it all:


Shell Sessions

(discovered via

The emacs embeded interpreter mode is very nice for interactively programming with languages like scheme and python. A similar effect can be achieved with the ScreenShell plugin and the following bindings:

vmap <C-c><C-c> :ScreenSend<CR> nmap <C-c><C-c> vip<C-c><C-c> nmap <C-x><C-e> :ScreenSend<CR>

Slimv is a more elaborate alternative (SLIME for vim).

Multi-Tab Setup

TODO: document my current multi-window configuration, how to re-scale, etc.

Ctrl-W = equalizes window sizes (Ctrl-W is the vierport meta sequence).


Do set spell to start spellchecking in "fly" mode (mispellings highlighted); do set nospell to undo.

Hovering over a word in visual, do zg to add the word to your dictionary, z= to show suggestions,


Digraphs are a simple mechanism for entering certin special characters (like τ, ā, etc) on a boring English/USA keyboard. RFC1345 defines a mapping between two-character digraph sequences and characters; these can be entered in vim from insert mode using C-k followed by the two characters. For example, while inserting, type C-k t * to get τ. In contemporary vim this comes though as the correct UTF-8 encoding.

For a long listing of characters, look at help digraphs-default, or this list of math-y characters: