我运行Debian 7.8服务器,安装了我能想到的所有vim包。
我的.profile包含:
if [ -e /usr/share/terminfo/x/xterm-256color ]; then
export TERM='xterm-256color'
else
export TERM='xterm-color'
fi
我的.vimrc包含:
set t_Co=256
set t_AB=^[[48;5;%dm
set t_AF=^[[38;5;%dm
然而当我打开一个随机的cpp文件并设置:语法时,我没有得到任何颜色,但是这个:
^[[38;5;14m//#include <unistd.h>
^[[38;5;81m#include ^[[38;5;13m"bouchonWifi.h"
^[[38;5;81m#include ^[[38;5;13m"string.h"
我已经检查过我的终端可以显示颜色了,因为perl脚本显示了所有256种颜色,ls是彩色的......
如何在vim中正确显示颜色?
答案 0 :(得分:0)
尝试this:
if !has("gui_running")
if &term == 'dterm'
set tsl=0 " Sun's terminal sucks bigtime
elseif has("terminfo") && ! (&term == 'linux' || &term == 'Eterm' || &term == 'vt220' || &term == 'nsterm-16color' || &term == 'xterm-16color')
" Force these terminals to accept my authority! (default)
" number of colors
set t_Co=16
" ANSI background
set t_AB=^[[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
" ANSI foreground
set t_AF=^[[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
elseif &term == 'term' || &term == 'rxvt' || &term == 'vt100' || &term == 'screen'
" Less-Cool Terminals (no terminfo)
set t_Co=16
set t_AB=^[[%?%p1%{8}%<%t4%p1%d%e%p1%{32}%+%d;1%;m
set t_AF=^[[%?%p1%{8}%<%t3%p1%d%e%p1%{22}%+%d;1%;m
else
" Terminals that have trustworthy terminfo entries
if &term == 'vt220'
set t_Co=8
" foreground
set t_Sf=^[[3%dm
" background
set t_Sb=^[[4%dm
elseif $TERM == 'xterm'
set term=xterm-color
endif
endif
endif
" enable filetype detection
if version >= 600
filetype plugin indent on
else
filetype on
endif
" make sure we have colors first
if &t_Co > 2 || has("gui_running")
syntax on
endif