First: Find out the cause of garbled characters. Always thought is the reason of the browser, the result I in CHROME,FIREFOX,IE9 inside all appear garbled, so the browser factor can be ruled out. In order to verify that my guess is the reason for Gvim,
I wrote a simple php file with Notepad (note)
Copy CodeThe code is as follows:
echo "Hello";
echo "World";
?>
The results did not appear garbled, so the problem is on the Gvim, this conclusion is inevitable.
So, began to study the Gvim configuration file (_VIMRC), now to everyone to see my garbled before the configuration (note: I have modified before):
Copy CodeThe code is as follows:
Set nocompatible
SOURCE $VIMRUNTIME/vimrc_example.vim
SOURCE $VIMRUNTIME/mswin.vim
Behave Mswin
Set Diffexpr=mydiff ()
function Mydiff ()
Let opt = '-a--binary '
If &diffopt =~ ' icase ' | Let opt = opt. '-I ' | endif
If &diffopt =~ ' Iwhite ' | Let opt = opt. '-B ' | endif
Let arg1 = v:fname_in
If Arg1 =~ ' | Let arg1 = ' "'. Arg1. '"' | endif
Let arg2 = V:fname_new
If Arg2 =~ ' | Let arg2 = ' "'. Arg2. '"' | endif
Let Arg3 = V:fname_out
If Arg3 =~ ' | Let Arg3 = ' "'. Arg3. '"' | endif
Let eq = '
If $VIMRUNTIME =~ '
If &sh =~ ' \ Let cmd = ' "". $VIMRUNTIME. ' \diff '
Let eq = ' "'
Else
Let cmd = substitute ($VIMRUNTIME, "', '" ', '). ' \diff "'
endif
Else
Let cmd = $VIMRUNTIME. ' \diff '
endif
Silent execute '! '. Cmd. ' ' . Opt. Arg1. ' ' . Arg2. ' > '. Arg3. eq
Endfunction
"Sets the default background color
Colors Desert
"Setting does not automatically backup
Set Nobackup
"Set default font and size
Set Guifont=courier_new:h12:cansi
Set TERMENCODING=GBK
Set Encoding=utf-8
"The cause of the problem
Set Fileencoding=chinese
Set Fileencodings=ucs-bom,utf-8,chinese
Set Langmenu=zh_cn.utf-8
SOURCE $VIMRUNTIME/delmenu.vim
SOURCE $VIMRUNTIME/menu.vim
Language Messages Zh_cn.utf-8
Language Messages Zh_cn.utf-8
Syntax enable
Syntax on
Here's what to enconding,fileeconding,fileecondings: The meaning of the config file:
Encoding:gvim the character encoding used internally, including the buffer of Vim, menu text, message text, and so on.
The user manual recommends changing its value only in. VIMRC, which in fact seems to only make sense if you change its value in. vimrc.
Fileencoding:gvim the character encoding of the currently edited file, Vim saves the file as a character encoding (regardless of whether the new file is the same).
Fileencodings:gvim starts by detecting the character encoding of the file to be opened by the character encoding it lists, and fileencoding is set to the final detected character encoding.
It is therefore best to place Unicode encoding at the top of this list, Latin1 Latin encoding to the last side.
Where: Chinese is cp963 code
Only here I suddenly remembered, my browsing in the default character set is GBK, and _VIMRC in the set code is UTF-8, the two do not correspond,
Copy CodeThe code is as follows:
Colors Desert
Set Nobackup
Set Guifont=courier_new:h12:cansi
"Processing text shows garbled characters
Set Encoding=utf-8
Set Fileencodings=chinese
Set Fileencoding=chinese
"Processing menu and right-click menu garbled
SOURCE $VIMRUNTIME/delmenu.vim
SOURCE $VIMRUNTIME/menu.vim
"Processing Consle output garbled
Language Messages Zh_cn.utf-8
Syntax enable
Syntax on
After the modification is complete, restart the Gvim, the Chinese garbled problem solved.
http://www.bkjia.com/PHPjc/323110.html www.bkjia.com true http://www.bkjia.com/PHPjc/323110.html techarticle First: Find out the cause of garbled characters. Always thought is the reason of the browser, the result I in CHROME,FIREFOX,IE9 inside all appear garbled, so the browser factor can be ruled out. To test ...