created 2004 · complexity basic · author Tony Mechelynck · version 5.7
The (long) line below comes from my vimrc. It adds, at the left of the right-hand part of the status line, a pair of square brackets containing the value of 'fileencoding' for the file you are editing (or that of 'encoding' if 'fileencoding' is empty). The file's encoding is followed by a comma and B if 'bomb' is functional and has the value 1 (TRUE).
Examples are [latin1], [iso-8859-15], [utf-8,B], etc.
The complexity of the value is due in large part to the necessity of (a) specifying explicitly the fields used implicitly when 'statusline' is empty (I hope I didn't forget any of them), and (b) backslash-escaping all spaces and quotation marks.
Now here it is:
if has("statusline") set statusline=%<%f\ %h%m%r%=%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"]\ \"}%k\ %-14.(%l,%c%V%)\ %P endif
References[]
Comments[]
Cool, but what if I have only one file open, that means I have no statusline but only the ruler? This script does not show me the enc then. Joachim
- Use
:set laststatus=2
to always show the statusline. :help 'laststatus' JohnBeckett 22:06, March 16, 2010 (UTC)