Say I am editing some file with vim (or gvim). I have no idea about the file's encoding and I want to know whether it is in UTF-8 or ISO-8859-1 or whatever? Can I somehow tell vim to show me what encoding is used?
Vim – How to Find the Encoding of the Current Buffer
character encodinggvimvim
Best Answer
The fileencoding setting shows the current buffer's encoding:
There really isn't a common way to determine the encoding of a plaintext file, as that information isn't saved in the file itself - except UTF-8 Files where you've got a so called BOM which indicates the Encoding. This is why xml and html files have charset metatags.
You can enforce a particular encoding with the 'encoding' setting. See
:help encoding
and:help fileencoding
in Vim for how the editor handles these settings. You can also add several fileencoding settings to your vimrc to have vim try detecting based on the ones listed.