NetworkingFiles
SecurityProNews
ITmanagement




Controlling Linux Colors In Vi (vim)

By: A.P. Lawrence
Expert Author
2005-03-16

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 ttty" 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

set t_Co=2

to the top of /etc/vimrc. I attempted to do this in ~/.vimrc but couldn't make it work, and also tried

if &term=="ansi"
  set t_Co=2
endif


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.

To my mind, colorizing is pretty messed up..

*Originally published at APLawrence.com


About the Author:
A.P. Lawrence provides SCO Unix and Linux consulting services http://www.pcunix.com
Newsletter Archive | Submit Article | Advertising Information | About Us| Contact

LinuxDeveloperNews is an iEntry, Inc.® publication © 1998-2008 All Rights Reserved Privacy Policy and Legal
iEntry Contact Advertise iEntry Jayde WebProWorld Forums Downloads News Article Archive About iEntry LinuxDeveloperNews Home Page LinuxDeveloperNews News