Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I notice one of my linux remote login window shows color in VI editor interface but another window doesn't show color. These 2 windows are remotely connected to 2 different server IP addresses.

Screenshots

May I know why and how to change the color of the VI screen? I am using Putty on Windows 7 to remotely access the linux server.

share|improve this question
    
Have you checked the settings in your PuTTY program? Maybe the settings are different for each login. I know you can change the color in PuTTY. –  Kevdog777 Jul 20 '12 at 15:01

2 Answers 2

You need to set your TERM in both to the same thing. If you use screen, those should be screen-256color-bce and if your terminal (urxvt for example) support 256 colours, you will get them. Note that vim requires set t_Co=256 in your ~/.vimrc to work properly.

I am assuming that you want colour to appear in all vi/vim windows. If not, just change your terminal (putty) to be black and white. You will then see no colours whatsoever.

share|improve this answer
    
Vim does not need explicit setting of the terminal's coloring capabilities if termcap or terminfo is set up correctly. That's what those are for. Setting t_Co=256 may actually be harmful when you run with a terminal that supports only 8 or 88 colors. –  user112553 Mar 16 '12 at 10:12
    
@user112553: Thank you for your clarification. –  Sardathrion Mar 16 '12 at 10:13
    
i am NOT using VIM and I am using VI only. Could you give more hints on this termcap or terminfo thing? –  Xianlin Mar 16 '12 at 12:03
1  
@Xianlin: As far as I know vi does not do colour highlighting. As for termcap/terminfo, this page should give you some information. –  Sardathrion Mar 16 '12 at 12:36
    
I think probably when I type "vi" in the second terminal the linux (ubuntu) actually is using vim program for me because I may installed vim unconsciously on the second server... –  Xianlin Mar 16 '12 at 14:46

By default (at least on Fedora and other Redhat derivitives) vim-enhanced is installed and it adds a file /etc/profile.d/vim.sh

alias vi=vim

So in your .bashrc or manually you can unalias vi and you'll get the uncolored vi interface you expect. I put the following in my standard bashrc

unalias vi 2> /dev/null
share|improve this answer
    
I am using ubuntu but thank you and I learned something new... –  Xianlin Mar 16 '12 at 14:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.