VIM set encoding fileencoding if the file is in windows-1251


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/code-flow.club/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
22 views
Good afternoon.

I have the files in cp-1251, containing Cyrillic characters. When I edit such a file, I have to install
:set encoding=cp1251
:set fileencoding=cp1251

Can vim to determine the file encoding cp1251 and set appropriate values of encoding and fileencoding?

Part of the project files in cp1251, some in utf8. It would be no problem to work with vim switch to different project files without problems with the permanent installations necessary encoding of the terminal and the file.

I feel somewhat inaccurate, but I hope ponyatno.
by | 22 views

3 Answers

0 like 0 dislike
:e ++enc=cp1251
by
0 like 0 dislike
Might help (auto-detect utf-8 files)
\r
"{{{ Locale settings "if we have BOM => this is the BOM if &fileencodings !~? "ucs-bom" set fileencodings^=ucs-bom endif if &fileencodings !~? "utf-8" let g:added_fenc_utf8 = 1 set fileencodings+=utf-8 endif if &fileencodings !~? "default" set fileencodins+=default endif "}}}

defined encodings
\r
set fileencodings=utf-8,cp1251,koi8-r,cp866

\r
Menu for fast encoding
\r
menu Encoding.koi8-r :e ++enc=koi8-r ++ff=unixmenu Encoding.windows-1251 :e ++enc=cp1251 ++ff=dosmenu Encoding.cp866 :e ++enc=cp866 ++ff=dosmenu Encoding.utf-8 :e ++enc=utf8menu Encoding.koi8-u :e ++enc=koi8-u ++ff=unixmap  :emenu Encoding.\r
by
0 like 0 dislike
sometimes enca from the same package.
by

Related questions

0 like 0 dislike
1 answer
asked Jun 8, 2019 by sibir007
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Jun 15, 2019 by IvanN777
110,608 questions
257,186 answers
0 comments
23,080 users