首先打开vim,输入命令 scriptnames看看vim加载了哪些脚本。
:scriptnames
输出入下
1: /home/users/xxx/.vimrc
2: /home/users/xxx/tools/share/vim/vim73/colors/darkblue.vim
3: /home/users/xxx/tools/share/vim/vim73/syntax/syntax.vim
4: /home/users/xxx/tools/share/vim/vim73/syntax/synload.vim
5: /home/users/xxx/tools/share/vim/vim73/syntax/syncolor.vim
6: /home/users/xxx/tools/share/vim/vim73/filetype.vim
7: /home/users/xxx/tools/share/vim/vim73/plugin/getscriptPlugin.vim
8: /home/users/xxx/tools/share/vim/vim73/plugin/gzip.vim
9: /home/users/xxx/tools/share/vim/vim73/plugin/matchparen.vim
10: /home/users/xxx/tools/share/vim/vim73/plugin/netrwPlugin.vim
11: /home/users/xxx/tools/share/vim/vim73/plugin/rrhelper.vim
12: /home/users/xxx/tools/share/vim/vim73/plugin/spellfile.vim
13: /home/users/xxx/tools/share/vim/vim73/plugin/tarPlugin.vim
14: /home/users/xxx/tools/share/vim/vim73/plugin/tohtml.vim
15: /home/users/xxx/tools/share/vim/vim73/plugin/vimballPlugin.vim
16: /home/users/xxx/tools/share/vim/vim73/plugin/zipPlugin.vim
可见所有和语法及颜色相关的脚本都已经加载了,应该不是它们的问题。
在看.vimrc配置文件
1 set nocompatible " Vim settings, not Vi settings. must be first
2 set autoindent " Auto align when insert new line, for instance, when using o or O to insert new line.
3 set ruler " Show ruler at the bottom-right of vim window
4 set showcmd
5 set backspace=indent,eol,start " Enable delete for backspace under insert mode"
6 colorscheme darkblue
7 set number " Show line number
8 syntax on
9 if &term =~ "xterm"
10 if has("terminfo")
11 set t_Co=8
12 set t_Sf=^[[3%p1%dm
13 set t_Sb=^[[4%p1%dm
14 else
15 set t_Co=8
16 set t_Sf=^[[3%dm
17 set t_Sb=^[[4%dm
18 endif
19 endif
从第9行开始,如果用的是xterm,那就就进行下面的颜色设置,那么如果系统用的不是xterm呢?于是赶紧查看,在shell终端输入如下命令
echo $TERM
结果如下
vt100+
果然不是xterm,怪不得没有颜色。
解决办法:打开shell配置文件,.bash_profile或.bashrc加入下面一行
TERM=xterm
export TERM
PS
1 set nocompatible " Vim settings, not Vi settings. must be first 2 set autoindent " Auto align when insert new line, for instance, when using o or O to insert new line. 3 set ruler " Show ruler at the bottom-right of vim window 4 set showcmd 5 set backspace=indent,eol,start " Enable delete for backspace under insert mode" 6 colorscheme darkblue 7 set number " Show line number 8 syntax on 9 if &term =~ "xterm" 10 if has("terminfo") 11 set t_Co=8 12 set t_Sf=^[[3%p1%dm 13 set t_Sb=^[[4%p1%dm 14 else 15 set t_Co=8 16 set t_Sf=^[[3%dm 17 set t_Sb=^[[4%dm 18 endif 19 endif
.bashrc加入下面
TERM=xterm
export TERM
再运行下脚本source .bashrc或source .bash_profile
修改终端设置
http://www.cnblogs.com/softwaretesting/archive/2012/01/10/2317820.html