Controlling Linux colors in vi (vim)
Got questions? Go ahead: Ask me anything!
Because of an old application that apparently partially looks at termcap and partially hard-codes terminal info, a customer has to set TERM=ansi when using Alphacom to access his Linux box.
The Linux colorizing fouls things up royally. You can shut off command line colorizing by editing /etc/DIR_COLORS and changing "COLOR tty" to "COLOR none" or (less drastically) by removing the "TERM ansi" line from the same file (which removes colorization for ansi but doesn't affect console use).
But that still leaves vi messing things up. The fix for that is to add
# t_C0=2 turns off MOST colors, 0 kills all
to the top of /etc/vimrc. I attempted to do this in ~/.vimrc but couldn't make it work, and also tried
in /etc/vimrc but that didn't work either.. not sure why yet. The idea there would be to let vim colorize if not using ansi, though in my case forcing it is fine because I don't want colors in vi ever.
I have seen the suggestion to "set syntax off"; that didn't work for me or the customer. I also tried using the "nosyntax.vim" file in /usr/share/vim/vim63/syntax, and even downloaded a "black and white" color scheme from http://www.vim.org/scripts/script.php?script_id=335, but vim still stubbornly would show colors for
errors. Only the t_Co=0 worked.
To my mind, colorizing is pretty messed up..
Also see Linux shell colors; shell ls colorization.
Got something to add? Send me email.
Increase ad revenue 50-250% with Ezoic
More Articles by Tony Lawrence
Find me on Google+
© 2011-04-13 Tony Lawrence