From 1052b067706dd242df58ca06e62c8f819a5d131f Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Fri, 31 Jan 2014 16:41:07 +0000 Subject: [PATCH] Show file encoding in the statusline. And BOM indicator if appropriate. --- .vimrc | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.vimrc b/.vimrc index d29cc40..88ef372 100644 --- a/.vimrc +++ b/.vimrc @@ -663,12 +663,37 @@ fun! Has_Unicode() "{{{2 endfun "}}}2 " Helper for status line. +" Show file encoding +func! Show_Encoding() "{{{2 + let l:enc = &fenc + if l:enc == "" + let l:enc = &enc + if l:enc == "" + return "" + endif + let l:enc = '(' . l:enc . ')' + endif + + if has("multi_byte") + if &bomb + if Has_Unicode() + let l:enc = l:enc . "☻" + else + let l:enc = l:enc . "@" + endif + endif + endif + + return l:enc . "," +endfun "}}}2 + +" Helper for status line. " Show space, underscore or dollar sign depending on list mode. fun! Show_List() "{{{2 call Iain_Vars() if w:iainlist == 0 " No list. - return " " + return "" elseif Has_Unicode() if w:iainlist == 1 " Just tabs. @@ -799,7 +824,7 @@ fun! Show_StatusLine() "{{{2 return endif call Iain_Vars() - let l:sl1='%2n\:\ %<%1*%f%0*\ [%{Show_List()}%{Show_Bind()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%{Show_VirtualEdit()}%{Show_Undo()}%Y%M%R%{Show_SearchForward()}]%{Show_Alt()}\ ' + let l:sl1='%2n\:\ %<%1*%f%0*\ [%{Show_Encoding()}%{Show_List()}%{Show_Bind()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%{Show_VirtualEdit()}%{Show_Undo()}%Y%M%R%{Show_SearchForward()}]%{Show_Alt()}\ ' let l:sl3='L:%1*%4.6l%0*/%-4.6L\ C:%1*%3.6c%V%0*\ \|\ %P' let l:hexformat='%b' if b:iainhex -- 2.7.4