"Why are we hiding from the police, Daddy? Because we use vim. Vim comic"

Vi Commands

vi key combocommand
:q!quit without saving
:wqwrite and quit
:%s/oldword/newword/gsubstitute all oldword occurences with newword in entire file
:lslist buffers
:b1switch to buffer 1
:bnswitch to buffer n
:vsvertically split window (create side by side windows)
dwdelete word
d$delete to end of line
dddelete current line
.repeat last change
yycopy, yank line into buffer
ppaste the line in buffer after cursor position
cwchange word
iinsert mode
<Esc>escape, exit insert mode
/VirtualHostsearch file for phrase "VirtualHost"
nmove to next occurence of search phrase
100Gmove to 100th line
1Gmove to first line
Gmove to last line

A list of the most common g commands

key combo command
gf Go to file under cursor
gv Go to last visual selection (and reselect)
gi Go to last inserted text
g; Go to prev change in changelist
g, Go to next change in changelist
gD Go to definition of word under cursor in current file
gU uppercase
gu lowercase

more vi cheatsheets



add to .screenrc to get Color Schemes working

attrcolor b ".I"
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
defbce "on"
term screen-256color-bce


" Colors!!
set t_Co=256

" color theme
colors elflord

set showmode "show current mode down the bottom

"Setting the status line...

set statusline=%f       "tail of the filename

"display a warning if the file format isn't Unix
set statusline+=%#warningmsg#
set statusline+=%{&amp;ff!='unix'?'['.&amp;ff.']':''}
set statusline+=%*

"display a warning if file encoding isn't UTf-8
set statusline+=%#warningmsg#
set statusline+=%{(&amp;fenc!='utf-8'&amp;&amp;&amp;fenc!='')?'['.&amp;fenc.']':''}
set statusline+=%*

set statusline+=%h      "help file flag
set statusline+=%y      "filetype
set statusline+=%r      "read only flag
set statusline+=%m      "modified flag
syntax on

Window Commands

C-w sSplit window horizontally
C-w vSplit window vertically
C-w xExchange windows
C-w wjump to next window
:onlykill all windows but current
C-w =equalize all window sizes

Edit Keys: used with argument

c change

  • cw = change word

d delete

  • d$ delete til end of line

r replace

  • r5 replace 5 chars

y yank

  • yy yank entire line