我在wnidows中的vim配置
set nocompatible
set nu
set ic
set ts=4
set shiftwidth=4
set fileencodings=utf-8,chinese,latin-1,ucs-bom,gb18030,big5,euc-jp,sjis,euc-kr,EUC
if has("win32")
" for chinese
set fileencoding=chinese
" for japanese-euc
" set fenc=euc-jp
" for japanese shift-jis
" set fenc=sjis
else
set fileencoding=utf-8
endif
"set enc=utf-8 "default for utf-8
"set for chinese GB2312
"set enc=cp936
"set fenc=cp936
"Just for show japanese
"set enc=cp932 "for jp_EUC
"set fenc=euc-jp "for jp_EUC
set enc=sjis "for shift-JIS
set fenc=sjis "for shift-JIS
set cindent
language message zh_CN.utf-8
"for jp language
"language message jp.utf-8
"language message
"解决乱码菜单
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"set font
set guifont=Nsimsun
set nobackup
set nobackup
colorscheme koehler
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 =~ '\<cmd'
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
" color default
:colorscheme darkblue
" language english
:lang eng
let fcomm = "fenc"
let optval = eval('&'.fcomm)
if optval=="cp936"
set guifont=Nsimsun
"echo "CP936"
elseif optval=="cp932"
set guifont=msmincho
elseif optval=="sjis"
set guifont=msmincho
endif
------------关于VIM中字体的设置---------------------
另外,还有一些有用的插件,见
http://learn.tsinghua.edu.cn:8080/2005212716/html/vimplugins.html
在控制台下的VIM是不能够改变字体的,因为字体的改变是随着终端字体的变化而变化的,但是在GVIM中,你却有权力将字体改变成自己想要的样子。
在Linux下设置字体的命令是:
: set guifont = Courier\ 14
而在Windows下则是:
: set guifont = Courier:h14
当然,如果需要设置多个字体,则我们可以在各个字体之间添加逗号(,)来设置多个字体,如:
: set guifont = Courier\ New\ 12 , Arial\ 10
如果字体名字中含有空格,则我们需要将其使用\进行转义,而在windows下则可以将空格转换为:字符。当然,这样设置之后只会对当前会话有效,而如果想每次都使用的话,则需要将其加入到其gvimrc设置文件中(将命令中前面的:去掉)。
如果你不知道可用的字体名字,使用下面的命令可以得到一个字体名字的列表:
:set guifont=*
如果需要想对特定的文件类型使用特定的字体,则可以将下面的语句加入到vimrc文件中去:
autocmd BufEnter *. txt set guifont = Arial \ 12
这样,在下次打开.txt文件的时候,就会设置字体Arial 12字体。