但行好事
莫论前程❤

vim没有颜色

转载自: 李阳博客

查看vim加载的脚本
vim
:scriptnames

输出如下:

  1: /etc/vimrc
  2: /usr/share/vim/vim72/filetype.vim
  3: /usr/share/vim/vim72/ftplugin.vim
  4: /usr/share/vim/vim72/plugin/filetype.vim
  5: /usr/share/vim/vim72/plugin/getscriptPlugin.vim
  6: /usr/share/vim/vim72/plugin/gzip.vim
  7: /usr/share/vim/vim72/plugin/matchparen.vim
  8: /usr/share/vim/vim72/plugin/netrwPlugin.vim
  9: /usr/share/vim/vim72/plugin/rrhelper.vim
 10: /usr/share/vim/vim72/plugin/spellfile.vim
 11: /usr/share/vim/vim72/plugin/tarPlugin.vim
 12: /usr/share/vim/vim72/plugin/tohtml.vim
 13: /usr/share/vim/vim72/plugin/vimballPlugin.vim
 14: /usr/share/vim/vim72/plugin/zipPlugin.vim
 15: /usr/share/vim/vim72/scripts.vim
 16: /usr/share/vim/vim72/ftplugin/vim.vim

经过与其他机器对比后,发现正常。

查看.vimrc文件

vim ~/.vimrc
set nocompatible        " Vim settings, not Vi settings.  must be first
set autoindent          " Auto align when insert new line, for instance, when using o or O to insert new line.
set ruler               " Show ruler at the bottom-right of vim window
set showcmd
set backspace=indent,eol,start          " Enable delete for backspace under insert mode"
colorscheme darkblue
set number              " Show line number
syntax on
if &term =~ "xterm"
  if has("terminfo")
    set t_Co=8
    set t_Sf=^[[3%p1%dm
    set t_Sb=^[[4%p1%dm
  else
    set t_Co=8
    set t_Sf=^[[3%dm
    set t_Sb=^[[4%dm
  endif
endif

实际上我的其它几台机器都没有这个文件,这里是别人的,只为了说明下面的问题。
我们看到第九行if &term =~ "xterm"这里的意思是如果用的是xterm就进行下面的颜色设置,如果不是呢?我们可以通过如下命令查看:

echo $TERM

结果为:

vt100+    或者
vt100

原来不是xterm,所以此时vim并没有颜色

解决办法:在.bash_profile.bashrc加入下面一行

TERM=xterm
export TERM

source一下以后再次运行vim,终于有颜色了,撒花🎉🎉🎉

赞(0) 打赏
未经允许不得转载:刘鹏博客 » vim没有颜色
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!

 

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏