Extracted from my .vimrc file. Just copy and paste to your own home folder's .vimrc file.
Highlighted customizations:
" Use Vim settings instead of Vi
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set autoindent
" keep 50 lines of command line history
set history=50
" show the cursor position all the time
set ruler
" display incomplete commands
set showcmd
" do incremental searching
set incsearch
" do highlight of matches in search
set hlsearch
" Don't use Ex mode, use Q for formatting
map Q gq
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if ∓t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 ∓∓ line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
endif " has("autocmd")
" enabling colors
set term=builtin_ansi
syntax on
" setting a command to clean up bad carriage returns.
" Remember: user defined commands start with capital letter !
command Repair %s/^M/\r/ge
" WARNING be sure to generate the above char as a control+V+M inside
" a vim session; it's not just a ^ plus an M character.
" tab complete ignores listed extensions
set wildignore=*.o,*.class
" cancel visualbell
set vb t_vb=
" map j to gj and k to gk, so line navigation ignores line wrap
nmap j gj
nmap k gk
" smart tab completion
function! InsertTabWrapper(direction)
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
elseif "back" == a:direction
return "\<c-p>"
else
return "\<c-n>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper ("forw")<cr>
inoremap <s-tab> <c-r>=InsertTabWrapper ("back")<cr>
# erase everything between "< " and ">" in all lines
:%s/< \_.\{-}>//g
# replace "<p class=chapter>Something" to "\chapter{Something}"
:%s/\(<p class=chapter>\)\(.*\)/\\chapter{\2}/g
# replace "<p class=subchapter>Some text" to "{\large Some text} followed by two line breaks
:%s/\(<p class=subchapter>\)\(.*\)/{\\large \2}\r\r/g
# replace back quotes with proper "
:%s/”/"/g
# replace & with \&
:%s/&/\\\&/g
# replace chapter{XX}, where X is 1 to infinity, with chapter
:%s/chapter{.\{-\}}/chapter/g
Of course all comands are documented under :he -the help command.
And please visit the best vim tips webpage ever. Also this one.