X-Git-Url: http://git.iain.cx/?p=profile.git;a=blobdiff_plain;f=.vimrc;h=9e94ae1024a033b6a072d45cd2112d132ed67d93;hp=6400b455d760234b06d456f0280aa1b24d909444;hb=e6b7d067305c80c6177a29ce106ac847d2e641cb;hpb=6262b23b90747594ff4c24cb9822973179911f98 diff --git a/.vimrc b/.vimrc index 6400b45..9e94ae1 100755 --- a/.vimrc +++ b/.vimrc @@ -27,12 +27,12 @@ endif :autocmd! " Set up our variables. -fun Iain_Vars() +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() +fun! Cycle_List() call Iain_Vars() let b:iainlist = b:iainlist + 1 if b:iainlist > 2 | let b:iainlist = 0 | endif @@ -47,7 +47,7 @@ fun Cycle_List() endif endfun -fun Show_List() +fun! Show_List() call Iain_Vars() if b:iainlist == 0 " No list. @@ -61,14 +61,14 @@ fun Show_List() endif endfun -" Cycle between hex and decimal display of toolbar stuff -fun Cycle_StatusLine() +" 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()}%{Show_Tabstop()}]%y%m%r\ %=0\x%02B\ (%3.6c,%-4.6l)\ 0\x%04.6O\ \|\ %4.6L\ %P + set statusline=%2n\:\ %<%f\ [%{Show_List()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%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()}%{Show_Tabstop()}]%y%m%r\ %=%b\ (%3.6c,%-4.6l)\ %4.6o\ \|\ %4.6L\ %P + set statusline=%2n\:\ %<%f\ [%{Show_List()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%Y%M%R]\ %=%b\ (%3.6c,%-4.6l)\ %4.6o\ \|\ %4.6L\ %P endif endfun @@ -83,33 +83,47 @@ if &diff | let &columns = 164 | endif map viwvbi"ea" map - yyp:s/./-/g:let @/='': map = yyp:s/./=/g:let @/='': -command W :w +command! W :w se tags=~/.ctags -fun Invert_Case() +" 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") + +fun! Invert_Case() let &ic = ! &ic endfun -fun Show_Case() +fun! Show_Case() if &ic | return "c" | else | return "C" | endif endfun -fun Show_Tabstop() +fun! Show_Tabstop() return &ts 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: +fun! Show_Paste() + if &paste | return "p" | else | return "" | endif +endfun + +" Clear Q as we will use it for commands. +map Q + +" Swap hex/decimal statusline with Qx +map Qx :call Cycle_StatusLine(): +" Swap case-sensitivity with Qc. +map Qc :call Invert_Case(): +" Cycle list styles with Ql. +map Ql :call Cycle_List(): +" Change to ts=2 with Q2. +map Q2 :se ts=2: +" Change to ts=4 with Q4. +map Q4 :se ts=4: +" Change to ts=8 with Q8. +map Q8 :se ts=8: + +" Vim 7 has tabs. Default "next tab" mapping is gt. Add "previous tab" as gb. +map gb :tabPrev call Cycle_StatusLine() @@ -127,11 +141,6 @@ au BufLeave * if &ft == "c" || &ft == "cpp" | call CMode_unmap() | endif 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 @@ -141,43 +150,33 @@ au BufLeave * if &ft == "make" | call MakeMode_unmap() | endif " ... For C-like languages: -fun CMode_map() +fun! CMode_map() set cinkeys=0{,0},:,0#,!^F,o,O,e set cinwords=if,else,while,do,for,switch endfun -fun CMode_unmap() +fun! CMode_unmap() endfun " .. For Perl files: -fun PerlMode_map() +fun! PerlMode_map() set cinkeys=0{,0},:,!^F,o,O,e set cinwords=if,else,while,do,for,eval endfun -fun PerlMode_unmap() +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() +fun! MakeMode_map() set list set noexpandtab endfun -fun MakeMode_unmap() +fun! MakeMode_unmap() set nolist set expandtab endfun