Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Old 04-27-2002, 06:34 AM   #1
Dr.Evil
Triple-A Player
 
Join Date: Mar 2002
Location: Denver, CO
Posts: 63
Question VIM 6.1 and syntax coloring

Hey all,

I'm having trouble getting vim's syntax highlighting to use ANSI colors in Terminal.app. I never had a problem with it before reinstalling my System last week, but now I can't get it to work with 6.0 (standalone install from osxgnu.org and fink version) or 6.1 (via fink). Is there a setting that I'm missing in my .vimrc? I'm just using the standard one (/sw/share/vim/vim61/vimrc_example.vim). I know it's not a problem with my Terminal settings because both lsc and bash have no problem with using colors.

Any help would be great.
Dr.Evil is offline   Reply With Quote
Old 04-29-2002, 03:01 AM   #2
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
In your vimrc file do you have

:syntax enable

or for the GUI version, check in the gvimrc file.

Cheers...
sao is offline   Reply With Quote
Old 04-29-2002, 04:41 AM   #3
Dr.Evil
Triple-A Player
 
Join Date: Mar 2002
Location: Denver, CO
Posts: 63
Quote:
Originally posted by sao
In your vimrc file do you have

:syntax enable

Yes. All it uses are bold and underline sequences, not color like it did before my reinstall. Trying colorscheme commands doesn't do anything, either. Is there some kind of ncurses support that I'm missing? I doubt that, since as I said, lsc and bash escape sequences work without a problem.
Dr.Evil is offline   Reply With Quote
Old 04-29-2002, 06:15 AM   #4
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
I don't know exactly what's going on with your settings, but you may want to try this suggestions from the manual :

There can be a number of reasons why you don't see colors:

- Your terminal does not support colors. Vim will use bold, italic and underlined text, but this doesn't look very nice. You probably will want to try to get a terminal with colors. For Unix, I recommend the xterm from the XFree86 project: |xfree-xterm|.

- Your terminal does support colors, but Vim doesn't know this.
Make sure your $TERM setting is correct. For example, when using an xterm that supports colors:

setenv TERM xterm-color

or (depending on your shell):

TERM=xterm-color; export TERM

The terminal name must match the terminal you are using.


or


Most color xterms have only eight colors. They should work with these lines in your .vimrc:

:if has("terminfo")
: set t_Co=8
: set t_Sf=<Esc>[3%p1%dm
: set t_Sb=<Esc>[4%p1%dm
:else
: set t_Co=8
: set t_Sf=<Esc>[3%dm
: set t_Sb=<Esc>[4%dm
:endif

[<Esc> is a real escape, type CTRL-V <Esc>]

You might want to put these lines in an ":if" that checks the name of your
terminal, for example:

:if &term =~ "xterm"
put above lines here
:endif

Note: Do these settings BEFORE doing ":syntax on". Otherwise the colors may be wrong.

Hope this helps. Let me know.


PS: What happens when you use Vim GUI and from the menu you select file and then color scheme?


Cheers...
sao is offline   Reply With Quote
Old 04-29-2002, 05:47 PM   #5
Dr.Evil
Triple-A Player
 
Join Date: Mar 2002
Location: Denver, CO
Posts: 63
Quote:
Originally posted by sao
Most color xterms have only eight colors. They should work with these lines in your .vimrc:

:if has("terminfo")
: set t_Co=8
: set t_Sf=<Esc>[3%p1%dm
: set t_Sb=<Esc>[4%p1%dm
:else
: set t_Co=8
: set t_Sf=<Esc>[3%dm
: set t_Sb=<Esc>[4%dm
:endif

[<Esc> is a real escape, type CTRL-V <Esc>]

Thanks. Adding those lines to my .vimrc took care of the problem without having to muck around with the TERM variable. I did specify initially that I was using Terminal.app.
Dr.Evil is offline   Reply With Quote
Old 04-29-2002, 10:55 PM   #6
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
Glad it worked.



Cheers...

Last edited by sao; 04-29-2002 at 10:58 PM.
sao is offline   Reply With Quote
Old 05-05-2002, 11:20 AM   #7
osxpez
Major Leaguer
 
Join Date: May 2002
Location: Sweden
Posts: 282
t_Co

I just put the following line in my .vimrc

let &t_Co = 8

Without any tests or anything. Should I ever use a terminal that doesn't support eight colors (like using my Palm device or some such) I only need execute

:let &t_Co = 2

from within vim.
__________________
/PEZ
osxpez is offline   Reply With Quote
Old 05-08-2002, 05:58 AM   #8
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
osxpez,

Yes,

let &t_Co = 8

works very fine.

Well, yours is short, mine is long.

Thanks.

Cheers...
sao is offline   Reply With Quote
Old 05-28-2002, 08:14 PM   #9
Dr.Evil
Triple-A Player
 
Join Date: Mar 2002
Location: Denver, CO
Posts: 63
Red face

I just upgraded to a newer iBook, so I had to go through all of this again.

let &t_Co = 8

doesn't work by itself, but sao's solution worked just fine, just as it did before. Just thought I'd report back on the issue.

Chad
Dr.Evil is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 06:12 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.