Monday, August 13, 2007

VIM vs. broken OSs/terminals :: colors are forever!

The tip was found in VIM's help under :help color-xterm and works for HP-UX and Solaris. I conditionally exclude Linux to be unaffected by workaround, since F/LOSS folks - compared to the Unix old farts - have managed somehow to ship decent terminfo/termcap boasting color support out of box.


if &t_Co > 0
" Linux/etc has proper terminfo
else
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
endif


The thing needs to be put into ~/.vimrc. The '^[' needs to be replaced by real escape character - ^V<Esc>.

No comments: