Vim Tips Wiki
Advertisement
Tip 735 Printable Monobook Previous Next

created May 28, 2004 · complexity basic · author A. J. 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


Advertisement