X-Git-Url: http://git.iain.cx/?p=profile.git;a=blobdiff_plain;f=.vimrc;h=945cb32515ebb6180bfb69d7707b817e574fb7fa;hp=9ca37c6ab0dc626e14dafdb8faaab368ff1fefd0;hb=e24134c28470ad4087848d77000e840a891319dd;hpb=8c75606a52da5a4df6018134e0806e7041ca69e1 diff --git a/.vimrc b/.vimrc index 9ca37c6..945cb32 100755 --- a/.vimrc +++ b/.vimrc @@ -1,4 +1,5 @@ " $Id$ +se nocp se ts=2 se bs=2 se sw=2 @@ -8,23 +9,171 @@ se cindent se cinkeys=0{,0},0),:,!^F,o,O,e se showcmd se go=agilmrtT +se hlsearch se incsearch se ignorecase se smartcase se shm=aot +se laststatus=2 syn enable if has("gui_running") se guifont=Bitstream\ Vera\ Sans\ Mono\ 12 colo darkblue endif +highlight StatusLine guifg=white guibg=blue ctermbg=white ctermfg=blue if has("win32") se guifont=Bitstream_Vera_Sans_Mono:h10:cANSI endif +:autocmd! + +" Set up our variables. +fun Iain_Vars() + if ! exists("b:iainlist") | let b:iainlist = 0 | endif + if ! exists("b:iainhex") | let b:iainhex = 1 | endif +endfun + +fun Cycle_List() + call Iain_Vars() + let b:iainlist = b:iainlist + 1 + if b:iainlist > 2 | let b:iainlist = 0 | endif + if b:iainlist == 0 + set nolist + elseif b:iainlist == 1 + set lcs=tab:\\_,trail:_,extends:<,precedes:> + set list + else + set lcs=tab:\\_,trail:_,extends:<,precedes:>,eol:$ + set list + endif +endfun + +fun Show_List() + call Iain_Vars() + if b:iainlist == 0 + " No list. + return " " + elseif b:iainlist == 1 + " Just tabs. + return "\\_" + else + " Full list. + return "\.\$" + endif +endfun + +" Cycle between hex and decimal display of toolbar stuff +fun Cycle_StatusLine() + call Iain_Vars() + let b:iainhex = ! b:iainhex + if b:iainhex + set statusline=%2n\:\ %<%f\ [%{Show_List()}][%{Show_Case()}]%y%m%r\ %=0\x%02B\ (%3.6c,%-4.6l)\ 0\x%04.6O\ \|\ %4.6L\ %P + else + set statusline=%2n\:\ %<%f\ [%{Show_List()}][%{Show_Case()}]%y%m%r\ %=%b\ (%3.6c,%-4.6l)\ %4.6o\ \|\ %4.6L\ %P + endif +endfun + +" Save the current window width so if we change it we can restore it +" when we quit. +let andyoldcols=&columns + +" This expands the terminal to display two 80-column files side-by-side +" when vim is opened in diff mode. +if &diff | let &columns = 164 | endif + map viwvbi"ea" map - yyp:s/./-/g:let @/='': map = yyp:s/./=/g:let @/='': 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 +se tags=~/.ctags + +fun Invert_Case() + let &ic = ! &ic +endfun + +fun Show_Case() + if &ic | return "ca" | else | return "Ca" | endif +endfun + +" Swap hex/decimal statusline with ,x +map ,x :call Cycle_StatusLine(): +" Swap case-sensitivity with ,c. +map ,c :call Invert_Case(): +" Cycle list styles with ,l. +map ,l :call Cycle_List(): +" Change to ts=2 with ,2. +map ,2 :se ts=2: +" Change to ts=4 with ,4. +map ,4 :se ts=4: +" Change to ts=8 with ,8. +map ,8 :se ts=8: + +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 PHP files: + +au BufEnter * if &ft == "php" | call PHPMode_map() | endif +au BufLeave * if &ft == "php" | call PHPMode_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 + +fun PHPMode_map() + set nocindent + set autoindent +endfun + +fun PHPMode_unmap() + set noautoindent + set cindent +endfun + +" ... For makefiles: + +fun MakeMode_map() + set list + set noexpandtab +endfun + +fun MakeMode_unmap() + set nolist + set expandtab +endfun