Vim 编辑器配置文件哪些选项是必备的
Vim 虽然操作起来很畅快,对于一个中文开发人员来说,Vim 的默认配置常常出现乱码。
其次是缩进问题,如何让不同系统平台看到的代码排版格式都一样式。
在参与开源项目时,有许多通用的代码规范,值得设为默认。
Answers
我一般把tab设为4个空格,然后换行用unix标准形式的<LF>。至于乱码问题,我用这段代码解决
if has("multi_byte")
set encoding=utf-8
" English messages only
"language messages zh_CN.utf-8
if has('win32')
language english
let &termencoding=&encoding
endif
set fencs=utf-8,gbk,chinese,latin1
set formatoptions+=mM
set nobomb " 不使用 Unicode 签名
if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
set ambiwidth=double
endif
else
echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"
endif