=======================Windows解决办法如下=======================
在$home/.vimrc(_vimrc)或在vim安装目录的_vimrc(.vimrc)文件中加入以下内容
set smarttab " 根据文件中其他地方的缩进空格个数来确定一个tab是多少个空格
set tabstop=4 " 表示一个table显示出来多少个空格
set shiftwidth=4 " 每一级缩进是多少个空格
set expandtab " 将tab扩展成空格
set autoindent " 继承前一行的缩进方式,特别适用于多行注释
set number " 显示行号
set ruler " 打开状态栏标尺
set iskeyword+=_,$,@,%,#,- " 带有如下符号的单词不要被换行分割
" 自选文件编码格式
" Multi-encoding setting, MUST BE IN THE BEGINNING OF .vimrc!
"
if has("multi_byte")
" When 'fileencodings' starts with 'ucs-bom', don't do this manually
"set bomb
set fileencodings=ucs-bom,chinese,taiwan,japan,korea,utf-8,latin1
" CJK environment detection and corresponding setting
if v:lang =~ "^zh_CN"
" Simplified Chinese, on Unix euc-cn, on MS-Windows cp936
set encoding=chinese
set termencoding=chinese
if &fileencoding == ''
set fileencoding=chinese
endif
elseif v:lang =~ "^zh_TW"
" Traditional Chinese, on Unix euc-tw, on MS-Windows cp950
set encoding=taiwan
set termencoding=taiwan
if &fileencoding == ''
set fileencoding=taiwan
endif
elseif v:lang =~ "^ja_JP"
" Japanese, on Unix euc-jp, on MS-Windows cp932
set encoding=japan
set termencoding=japan
if &fileencoding == ''
set fileencoding=japan
endif
elseif v:lang =~ "^ko"
" Korean on Unix euc-kr, on MS-Windows cp949
set encoding=korea
set termencoding=korea
if &fileencoding == ''
set fileencoding=korea
endif
endif
" Detect UTF-8 locale, and override CJK setting if needed
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set encoding=utf-8
endif
else
echoerr 'Sorry, this version of (g)Vim was not compiled with "multi_byte"'
endif
"解决菜单乱码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"解决consle输出乱码
language messages zh_CN.utf-8
注意:如果添加以上编码后菜单出现乱码则删除红字部分。
=======================Linux解决办法如下=======================
在$home/.vimrc(_vimrc)或在vim安装目录的_vimrc(.vimrc)文件中加入以下内容
set smarttab " 根据文件中其他地方的缩进空格个数来确定一个tab是多少个空格
set tabstop=4 " 表示一个table显示出来多少个空格
set shiftwidth=4 " 每一级缩进是多少个空格
set expandtab " 将tab扩展成空格
set autoindent " 继承前一行的缩进方式,特别适用于多行注释
set number " 显示行号
set ruler " 打开状态栏标尺
set iskeyword+=_,$,@,%,#,- " 带有如下符号的单词不要被换行分割
" 自选文件编码格式
set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8
set fileformats=unix
set encoding=prc