vim, gvim under windows Chinese garbled ultimate solution

Vim used to believe that people will deeply love this editor, because its efficiency is too high! However, for people who use Vim on Windows system will run into a little trouble: File garbled, garbled menu, right-click menu garbled, conlse garbled output, file associations context menu garbled ......

vim under windows Chinese font is not good, so we need to adjust the font display encoded as utf-8, the only way to use beautiful Chinese.

There is a simple way to solve the garbage problem: Remove lang directory of vim. But all this can only be displayed in English the menu.

The ultimate solution vim, gvim in windows under Chinese garbled:

set encoding=utf-8
set fileencodings=utf-8,chinese,latin-1
if has("win32")
set fileencoding=chinese
else
set fileencoding=utf-8
endif
"解决菜单乱码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"解决consle输出乱码
language messages zh_CN.utf-8

Attachment:

View the file encoding:

:echo &fileencoding

Vim has four options with the character encoding related, encoding, fileencoding, fileencodings, termencoding (these options Possible values ​​refer to the Vim online help: help encoding-names), their meaning is as follows:

encoding: character encoding used inside Vim, Vim comprising a buffer (buffer), menu text, text messages and the like.
fileencoding: character encoding Vim to edit a file present, will save the file when Vim save files as this character encoding (whether new documents are true).
fileencodings: it will follow the character encoding listed one by one to detect the character encoding of the file will open Vim starts, and fileencoding set as the final detected character encoding. So it is best to Unicode encoding into the top of the list, the Latin latin1 encoding into the final surface.
termencoding: Vim end of the work (or the Console window Windows) character encoding. This option gVim our common GUI mode is not available under Windows, but in terms of Vim Console mode Console is a Windows code page, and usually we do not need to change it.
Preferably menus and prompts in English, can be removed from the following set of menus and prompts (B, C portion). If English menus and prompts in the installation of gvim will support the option to remove the local language.

Vim solve garbled file, open the file garbled, menu, garbled message:

There are four options with the character encoding related, encoding, fileencoding, fileencodings, termencoding
modified in linux .vimrc (is _vimrc in the win)

windows system can also vim menu items: Edit> Start setting, directly open files _vimrc

A,"设置文件的代码形式
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,chinese,cp936

B,"vim的菜单乱码解决:
"同样在 _vimrc文件里以上的中文设置后加上下列命令,
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim

C,"vim提示信息乱码的解决
language messages zh_CN.utf-8

Guess you like

Origin www.cnblogs.com/enumx/p/12333939.html