My vim cheatsheet

Search and replace

/* Search, where * is a regex term.

n Find next search item. (N find previous search item)

:%s/before/after/g Replace all.

:5,12s/before/after/g Replace between lines 5 and 12.

Movement

<line-number>gg Jump to line number.

0 Go to beginning of line. (^ for non-empty, I for insert mode)

$ Go to end of line. (A for eol and insert mode)

ctrl+u Jump up half a page, while maintaining cursor position.

ctrl+d Jump down half a page, while maintaining cursor position.

# Find next occurence of word under the cursor.

df* Delete up to and including a character.

dt* Delete until a character, but not including it.

% Jump to matching brace.

Display & Symbols

:set list Show all symbols. (:set nolist to toggle off)

ctrl+v tab To insert a literal tab symbol.

:set number Show line numbers. (:set nonumber to toggle off)

v or ctrl+v to select, then u for lowercase, U for uppercase.

Misc

u Undo ctrl+r Redo

My .vimrc

Either replace it automatically with:

$ curl -sL scott-liu.com/mysetup.sh

Or paste what you like from it:

syntax on
" apply current indentation to next
set autoindent
" tabs = how many spaces
set tabstop=4
" indent next line with this many spaces
set shiftwidth=4
" tabs actually give spaces
set expandtab
" gives current line number on bottom right
set ruler
" more yanks across files
set viminfo='20,<1000
" highlight search as you type
set incsearch