R
R
Roman Konofeev2016-02-05 19:21:17
vim
Roman Konofeev, 2016-02-05 19:21:17

How to set file encoding when opening?

There are files of the same type, but it so happened that some are encoded in cp1251 and some in cp866 .
How to make it so that when opening the encoding was cp1251 , but you can change it manually?
To change the file encoding manually, use the following menu:

set wildmenu
set wcm=<TAB>
menu Encoding.windows-1251 :e ++enc=cp1251<CR>
menu Encoding.cp866        :e ++enc=cp866<CR>
menu Encoding.koi8-r       :e ++enc=koi8-r<CR>
menu Encoding.utf-8        :e ++enc=utf-8<CR>
map <F8> :emenu Encoding.<TAB>

Created a file (by type) in the ftplugin
directory. If you specify the encoding in it e ++enc=cp1251, then you can’t change it manually.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lo-fi, 2017-07-11
@hrls

If the file syntax supports comments, then you can try setting the encoding for each file via modeline ( :h modeline).
Else try something like autocmd BufRead *.foo set encoding=barin vimrc/ftplugin

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question