X-Git-Url: http://git.iain.cx/?p=profile.git;a=blobdiff_plain;f=.vimrc;h=eac19ca2c928c9722373714641e6400eff69dcb6;hp=ba4ec764204933fbdad2b5da05a26c224c7f44ec;hb=9bc7cefe316314c162241101a15de05d96033256;hpb=a26d4be47a73651f248068ab25d5b38a09451b10 diff --git a/.vimrc b/.vimrc index ba4ec76..eac19ca 100755 --- a/.vimrc +++ b/.vimrc @@ -29,20 +29,22 @@ endif " 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 + if ! exists("b:iainhex") | let b:iainhex = 0 | endif endfun +" Change list mode. fun! Cycle_List() + let basic='tab:\\_,trail:_,extends:<,precedes:>' 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:> + exec "set lcs=" . basic set list else - set lcs=tab:\\_,trail:_,extends:<,precedes:>,eol:$ + exec "set lcs=" . basic . ",eol:$" set list endif endfun @@ -62,14 +64,21 @@ fun! Show_List() endfun " Cycle between hex and decimal display of toolbar stuff. -fun! Cycle_StatusLine() +fun! Cycle_HexStatusLine() call Iain_Vars() let b:iainhex = ! b:iainhex + call Show_StatusLine() +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 hexformat='%b' 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 - else - set statusline=%2n\:\ %<%f\ [%{Show_List()}%{Show_Case()}%{Show_Tabstop()}%Y%M%R]\ %=%b\ (%3.6c,%-4.6l)\ %4.6o\ \|\ %4.6L\ %P + let hexformat='0\x%02B' endif + exec "set statusline=" . sl1 . hexformat . sl2 endfun " Save the current window width so if we change it we can restore it @@ -86,6 +95,10 @@ map = yyp:s/./=/g:let @/='': command! W :w se tags=~/.ctags +" 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 @@ -98,20 +111,40 @@ 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: - -call Cycle_StatusLine() +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_HexStatusLine(): +" 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: +" Change to ts=16 with Q6. +map Q6 :se ts=16: +" Change to ts=32 with Q3. +map Q3 :se ts=32: +" Change foldmethod with Qf. +map Qf :se foldenable!: +" Change number mode with Qn. +map Qn :se number!: +" Toggle paste mode with Qp. +map Qp :se paste!: + +" Vim 7 has tabs. Default "next tab" mapping is gt. Add "previous tab" as gb. +map gb :tabPrev + +call Show_StatusLine() au VimLeave * if exists("andyoldcols") | let &columns=andyoldcols | endif @@ -127,11 +160,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 @@ -160,16 +188,6 @@ 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()