From: Iain Patterson Date: Wed, 14 Jul 2010 10:40:02 +0000 (+0100) Subject: Show alternate buffer in statusline. X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=b56e855aaea960ba3cd6fb04e5e5360396441920;p=profile.git Show alternate buffer in statusline. Toggle showing alternate buffer number and name for the current buffer, if it exists, with #. Off by default. --- diff --git a/.vimrc b/.vimrc index a589ea0..68357f3 100644 --- a/.vimrc +++ b/.vimrc @@ -204,6 +204,7 @@ fun! Iain_Vars() "{{{2 call Prep_Var("g:iainextracolumnsnumber", "''") call Prep_Var("g:iainextracolumnslist", "''") call Prep_Var("b:iaincul", 0) + call Prep_Var("b:iainalt", 0) if has("signs") call Prep_Var("g:marksigns", 0) call Prep_Var("g:firstsign", 100) @@ -449,6 +450,8 @@ call Mapping(">", ":call Resize_Columns('+'):") call Mapping("<", ":call Resize_Columns('-'):") " Clear search pattern with \/. call Mapping("/", ":let @/=\"\":") +" Toggle alternate buffer name with \#. +call Mapping("#", ":call Cycle_Alt():") " Set graphical window title. if has("win32") || has("win64") @@ -659,13 +662,24 @@ fun! Show_Paste() "{{{2 endif endfun "}}}2 +" Helper for status line. +" Show alternate buffer number and name. +fun! Show_Alt() "{{{2 + let l:alt = bufnr("#") + if l:alt < 0 || l:alt == bufnr("") || ! b:iainalt + return "" + endif + + return " " . l:alt . ": " . expand("#:t") +endfun "}}}2 + " Show the status line. fun! Show_StatusLine() "{{{2 if ! has("statusline") return endif call Iain_Vars() - let l:sl1='%2n\:\ %<%1*%f%0*\ [%{Show_List()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%Y%M%R]\ ' + let l:sl1='%2n\:\ %<%1*%f%0*\ [%{Show_List()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%Y%M%R]%{Show_Alt()}\ ' let l:sl3='L:%1*%4.6l%0*/%-4.6L\ C:%1*%3.6c%0*\ \|\ %P' let l:hexformat='%b' if b:iainhex @@ -949,6 +963,13 @@ fun! Cycle_Quickfix() "{{{2 endif endfun "}}}2 +" Toggle showing alternate buffer information. +fun! Cycle_Alt() "{{{2 + call Iain_Vars() + let b:iainalt = ! b:iainalt + call Show_StatusLine() +endfun "{{{2 + " Swap hex/decimal statusline with \x. call Mapping("x", ":call Cycle_HexStatusLine():") " Change statusline verbosity with \v.