From d9f6041145fbc121fbaadc056a6e7853246bf06f Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Wed, 20 Jun 2007 08:47:11 +0000 Subject: [PATCH] Trying to handle multiple toggles of number mode in split windows. Show numbers in blue. Set consistent width of numbers column. git-svn-id: https://svn.cambridge.iain.cx/profile/trunk@54 6be0d1a5-5cfe-0310-89b6-964be062b18b --- .vimrc | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/.vimrc b/.vimrc index e803032..c594723 100755 --- 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 @@ -217,6 +219,13 @@ endif if version >= "600" version 6.0 +" Allow room for numbers. +se numberwidth=5 + +" Track changing number mode. +let g:numbercols=&columns +let g:numberchanges=0 + " Less intrusive syntax highlighting. syn enable @@ -237,6 +246,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 +279,46 @@ fun! Cycle_HexStatusLine() 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... 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 + let &columns=&columns+&numberwidth + 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 -- 2.20.1