Controlling Linux colors in vi (vim)



Author: TonyLawrence
Date: Mon Mar 14 16:49:35 2005
Subject: Controlling Linux colors in vi (vim)

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).


Hate these ads?

But that still leaves vi messing things up. The fix for that is to add

 
set t_Co=0 
# 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



if &term=="ansi" 
  set t_Co=0 
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. 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..



Comments /Forum/TonyLawrence10.html


Mon Mar 14 20:22:47 2005: Subject:   TonyLawrence
Frustratingly, the person who originally had this problems says that his screen still turns blue in vi.. with Alphacom, but not Powerterm.. makes no sense to me, but we'll ask the Alphacom folks if they can shed any light on this..



Wed Mar 16 20:42:38 2005: Subject:   TonyLawrence
Just the difference between t_Co=0 and t_Co=2




Sat Sep 24 23:00:56 2005: Subject:   BigDumbDinosaur
I personally find vim's use of text colors real annoying, primarily because I'm partially color-blind. On my SCO box (which is where I still do a lot of my work) I either work in monochrome (usually green on black -- old habits die slowly) or have set text colors that are high contrast and do not mix blues and greens (my color-blindness is the relatively rare blue-green type -- most color-blindness is red-green). The widespread use of blue backgrounds in applications poses a real problem for me, as combinations like black on blue, light green on blue and so on are barely visible to me. The page borders displayed on this site when running in border mode are almost invisible relative to the white background of the main frame. Another visually annoying application I use is Microlite's Backup Edge. The default color combination (blue background, white foreground) results in an eye-watering session.



Mon Jun 26 05:42:59 2006: Subject:   anonymous
this works on an ad-hoc basis:


:syn off

Tue Aug 22 04:23:14 2006: Subject:   anonymous
I too am colorblind (juts red-green here). As if that's not bad enough, I am ADHD too. The colors are not only annoying but incredibly distracting. Just give me my text--nothing fancy, just good ol' vi!



Wed Jan 3 17:16:44 2007: Subject: color highlighting for comment in VI   vp70
do following to change color highlighting for comment from darkblue (default) to darkgray



if &term=="rxvt"
set term=xterm
endif
if &term=="xterm" || &term=="rxvt"
set t_Co=8
map ,u :source ~/.vimrc<CR>
endif
syntax enable
hi Comment cterm=none ctermfg=darkgray ctermbg=none


Thu Jan 11 03:23:30 2007: Subject: Gail   anonymous
I agree that color in vi is messed up at least on my redhat linux system in an xterm. Sorry, but I did not find the suggestion here helpful. Exactly where does one type the magic "set t_Co=0"?



However, for straight up vi (i.e. not vim) , the suggestion here worked like a charm.

http://www.cyberciti.biz/faq/turn-on-or-off-color-syntax-highlighting-in-vi-or-vim/

Thanks for a great and helpful site and forum.




Thu Jan 11 11:59:01 2007: Subject:   TonyLawrence
You add it to /etc/vimrc



How can you say it didn't work if you didn't know where to add it? :-) That link you gave is just the "set syntax off", which as I said above didn't work for me. I think that shows how screwy vim is: one thing works for you, the other for me. It's a messed up thing.

Fri Feb 1 21:07:38 2008: Subject: Vim   RichardBronosky


Vim is perfect. We are flawed. Anytime I think Vim has a problem, I find that I am wrong about 6 months later.

Fri Feb 1 22:28:06 2008: Subject:   TonyLawrence


Well, I'm a big vi fan - every single page I post here was written with vi - but it does have its faults just the same :-)

Add your comments

Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)

Or use any RSS reader

Delivered by FeedBurner

cartoon
Need eyes on the ground at your customer's site?
Installation and light training Boston and New England
Reliable and experienced, punctual and professional.

Views for this page
Today This Week This Month This Year  Overall
31100784,470 32,182

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

pavatar.jpg
More:
       - Shell
       - Linux
       - Unix
       - Forum




Unix/Linux Consultants

Your ad here - $24.00 yearly!

http://www.cleverminds.net Need expert advice? Want a second opinion? CleverMinds is a one-stop-shop for a wide range of technology solutions. We support Unix, Linux, SCO as well as CMS, ecom, blogs, podcasts, search engines consulting and more. Contact us at web2.0@cleverminds.net 0r (617) 894-1282


http://thatitguy.com Business networking servers, Linux and Unix experts. In business since 1997! Windows and Exchange to Samba and Scalix migration experts.


larryi@ccamedical.com SCO OS5, Debian Linux, RedHat Linux, MySQL, Apache, AJAX development using dXport/dL4/Unibasic, Windows Connectivity, Sharing Resouces, Automation, Shell Scripting




Twitter
  • Jun 26 21:28
    Lost 5 cents at poker tonight. Hard to do with 10 and 20 cent betting..
  • Jun 23 07:01
    Hypermiling:









Change Congress

Related Posts