-command W :w
-:autocmd!
-autocmd Syntax c se cinkeys=0{,0},0),:,0#,!^F,o,O,e
-autocmd Syntax perl se cinkeys=0{,0},0),:,!^F,o,O,e
-autocmd Syntax php se cinkeys=0{,0},0),:,!^F,o,O,e
+command! W :w
+se tags=~/.ctags
+
+" Make * and # work the way you expect in visual mode.
+vnoremap * y/\V<C-R>=substitute(escape(@@,"/\\"),"\n","\\\\n","ge")<CR><CR>
+vnoremap # y?\V<C-R>=substitute(escape(@@,"?\\"),"\n","\\\\n","ge")<CR><CR>
+
+fun! Invert_Case()
+ let &ic = ! &ic
+endfun
+
+fun! Show_Case()
+ if &ic | return "c" | else | return "C" | endif
+endfun
+
+fun! Show_Tabstop()
+ return &ts
+endfun
+
+fun! Show_Paste()
+ if &paste | return "p" | else | return "" | endif
+endfun
+
+" Clear Q as we will use it for commands.
+map Q <Nop>
+
+" Swap hex/decimal statusline with Qx
+map Qx :call Cycle_StatusLine()<CR>:<CR>
+" Swap case-sensitivity with Qc.
+map Qc :call Invert_Case()<CR>:<CR>
+" Cycle list styles with Ql.
+map Ql :call Cycle_List()<CR>:<CR>
+" Change to ts=2 with Q2.
+map Q2 :se ts=2<CR>:<CR>
+" Change to ts=4 with Q4.
+map Q4 :se ts=4<CR>:<CR>
+" Change to ts=8 with Q8.
+map Q8 :se ts=8<CR>:<CR>
+
+" Vim 7 has tabs. Default "next tab" mapping is gt. Add "previous tab" as gb.
+map gb :tabPrev<CR>
+
+call Cycle_StatusLine()
+
+au VimLeave * if exists("andyoldcols") | let &columns=andyoldcols | endif
+
+" Autocommands to setup features we only want in certain modes...
+
+" ... For C/C++ files:
+
+au BufEnter * if &ft == "c" || &ft == "cpp" | call CMode_map() | endif
+au BufLeave * if &ft == "c" || &ft == "cpp" | call CMode_unmap() | endif
+
+" ... For Perl files:
+
+au BufEnter * if &ft == "perl" | call PerlMode_map() | endif
+au BufLeave * if &ft == "perl" | call PerlMode_unmap() | endif
+
+" ... For makefiles:
+
+au BufEnter * if &ft == "make" | call MakeMode_map() | endif
+au BufLeave * if &ft == "make" | call MakeMode_unmap() | endif
+
+" Functions to call when we enter/leave a programming language buffer...
+
+" ... For C-like languages:
+
+fun! CMode_map()
+ set cinkeys=0{,0},:,0#,!^F,o,O,e
+ set cinwords=if,else,while,do,for,switch
+endfun
+
+fun! CMode_unmap()
+endfun
+
+" .. For Perl files:
+
+fun! PerlMode_map()
+ set cinkeys=0{,0},:,!^F,o,O,e
+ set cinwords=if,else,while,do,for,eval
+endfun
+
+fun! PerlMode_unmap()
+ set foldmethod=manual
+endfun
+
+" ... For makefiles:
+
+fun! MakeMode_map()
+ set list
+ set noexpandtab
+endfun
+
+fun! MakeMode_unmap()
+ set nolist
+ set expandtab
+endfun