X-Git-Url: http://git.iain.cx/?p=profile.git;a=blobdiff_plain;f=.vimrc;h=1d7d9d70fde6bde61472fb02b9af7d57caae528c;hp=e803032a88088013c895248d4758bf3077bb7a30;hb=7bf0efc96c2bb133d2d884030ac39437f8ae7895;hpb=6a5d3d5b7070c7026e498deb92c814377cc37256 diff --git a/.vimrc b/.vimrc old mode 100755 new mode 100644 index e803032..1d7d9d7 --- a/.vimrc +++ b/.vimrc @@ -1,6 +1,8 @@ """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " $Id$ """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Multi-version vimrc compatible with version 4 and above. +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Note that "if | call Something() | endif" syntax is unsupported " in Vim 4 so we write all our functions out the long way. It does work in @@ -37,6 +39,7 @@ se laststatus=2 " Use C indent style. se cindent se cinkeys=0{,0},0),:,!^F,o,O,e +se cinoptions=b1,c2 " GUI options. se go=aglmr @@ -96,6 +99,9 @@ fun! Iain_Vars() if ! exists("b:iainhex") let b:iainhex = 0 endif + if ! exists("b:iainverbose") + let b:iainverbose = 0 + endif endfun " Helper for status line. @@ -144,12 +150,17 @@ endfun fun! Show_StatusLine() call Iain_Vars() let sl1='%2n\:\ %<%f\ [%{Show_List()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%Y%M%R]\ %=' - let sl2='\ \|\ P:%4.6o\ L:%4.6l/%-4.6L\ C:%3.6c\ \|\ %P' + let sl3='L:%4.6l/%-4.6L\ C:%3.6c\ \|\ %P' let hexformat='%b' if b:iainhex let hexformat='0\x%02B' endif - exec "set statusline=" . sl1 . hexformat . sl2 + if b:iainverbose + let sl2=hexformat . '\ \|\ P:%4.6o\ ' + else + let sl2='' + endif + exec "set statusline=" . sl1 . sl2 . sl3 endfun " Restore window size. @@ -217,6 +228,10 @@ endif if version >= "600" version 6.0 +" Track changing number mode. +let g:numbercols=&columns +let g:numberchanges=0 + " Less intrusive syntax highlighting. syn enable @@ -229,6 +244,9 @@ if has("win32") se guifont=Bitstream_Vera_Sans_Mono:h10:cANSI endif +" Ignore whitespace when diffing. +se diffopt=filler,iwhite + " Expand window when doing a vertical diff. if &diff let &columns = 164 @@ -237,6 +255,9 @@ endif " Status bar matches the colour. highlight StatusLine guifg=white guibg=blue ctermbg=white ctermfg=blue +" Numbers in blue. +highlight LineNr term=underline cterm=bold guifg=blue ctermfg=blue + " Make * and # work the way you expect in visual mode. vnoremap * y/\V=substitute(escape(@@,"/\\"),"\n","\\\\n","ge") vnoremap # y?\V=substitute(escape(@@,"?\\"),"\n","\\\\n","ge") @@ -267,26 +288,60 @@ fun! Cycle_HexStatusLine() call Show_StatusLine() endfun +" Cycle verbose display of toolbar stuff. +fun! Cycle_VerboseStatusLine() + call Iain_Vars() + let b:iainverbose = ! b:iainverbose + call Show_StatusLine() +endfun + +" Cycle between number mode. +" FIXME: Toggling in a split window doesn't work properly. We need to track +" the number of windows and number modes. Something for later... +" Perhaps have a redraw callback that checks width and original column number. fun! Cycle_Number() if &number " Restore width. if &t_WS =~ '^.' - let &columns=g:numbercols + " Track changes. + let g:numberchanges=g:numberchanges-1 + if g:numberchanges<0 + g:numberchanges=0 + endif + + " Change size back if this was the last window. + if g:numberchanges == 0 + let &columns=g:numbercols + endif endif set nonumber else " Save width between number toggling. if &t_WS =~ '^' - let g:numbercols=&columns - let &columns=&columns+5 + " Expand if this was the first change. + if g:numberchanges == 0 + let g:numbercols=&columns + if version >= 700 + " Expand column by our preferred width. + let &columns=&columns+&numberwidth + else + " Vim 6 hardcodes width to 8. + let &columns=&columns+8 + endif + endif + + " Track changes. + let g:numberchanges=g:numberchanges+1 endif set number endif endfun +" Toggle case-sensitivity. fun! Invert_Case() let &ic = ! &ic endfun + " We'll use Q for various commands. Unmap it. map Q @@ -306,6 +361,8 @@ map Qf :se foldenable!: map Qp :se paste!: " Swap hex/decimal statusline with Qx map Qx :call Cycle_HexStatusLine(): +" Change statusline verbosity with Qv +map Qv :call Cycle_VerboseStatusLine(): " Swap case-sensitivity with Qc. map Qc :call Invert_Case(): " Cycle list styles with Ql. @@ -314,6 +371,8 @@ map Ql :call Cycle_List(): map Qn :call Cycle_Number(): " Toggle tags with Qt. map Qt :Tlist +" Clear search pattern with Q/. +map Q/ :let @/="": " Leaving Perl mode. fun! PerlMode_unmap() @@ -329,6 +388,12 @@ endif if version >= "700" version 7.0 +" Make diffs vertical by default. +se diffopt+=vertical + +" Set size of numbers column. +se numberwidth=5 + " Add "previous tab" mapping as gb. map gb :tabPrev endif