|
|
 | | From: | nospam at geniegate.com | | Subject: | VIM: force color term? | | Date: | Wed, 12 Jan 2005 02:28:51 GMT |
|
|
 | This has to be a FAQ, I've seen lots of answers but none that really satisfy what I want to do.
I'd like to tell vim if I have a color terminal, either in it's ini or as a setting.
The stuff I'd seen so far involve setting environment variables that tend to break other programs :-(
Is there a simple command or setting that says: "this is a color terminal" or "this is a monochrome terminal" ?
Jamie -- http://www.geniegate.com Custom web programming guhzo_42@lnubb.pbz (rot13) User Management Solutions
|
|
 | | From: | Gary Johnson | | Subject: | Re: VIM: force color term? | | Date: | Wed, 12 Jan 2005 03:10:50 +0000 (UTC) |
|
|
 | nospam@geniegate.com wrote: > This has to be a FAQ, I've seen lots of answers but none that > really satisfy what I want to do. > > I'd like to tell vim if I have a color terminal, either in it's > ini or as a setting. > > The stuff I'd seen so far involve setting environment variables > that tend to break other programs :-( > > Is there a simple command or setting that says: "this is a color > terminal" or "this is a monochrome terminal" ?
That's what the terminfo and termcap databases are for. With either of those, a properly-set TERM variable and a properly-compiled vim, the selection of color or monochrome should "just work." The only environment variable you should need is TERM. There is no reason for a correct TERM setting to break anything. Is there some reason that TERM isn't being set correctly?
Even if you don't have a working terminfo or termcap database, you can use TERM to set vim's colors by following the suggestions in
:help color-xterm
For a general discussion of vim and terminals, see
:help terminal-info
If you want to tell vim the kind of terminal it is running in when you start it and for some reason TERM won't work for you, you can use the -T option.
HTH, Gary
|
|
 | | From: | Bob Harris | | Subject: | Re: VIM: force color term? | | Date: | Wed, 12 Jan 2005 03:24:41 GMT |
|
|
 | In article , nospam@geniegate.com wrote:
> This has to be a FAQ, I've seen lots of answers but none that really satisfy > what > I want to do. > > I'd like to tell vim if I have a color terminal, either in it's ini or as a > setting. > > The stuff I'd seen so far involve setting environment variables that tend to > break > other programs :-( > > Is there a simple command or setting that says: "this is a color terminal" or > "this is a monochrome terminal" ? > > > Jamie
My standard answer. So far it seems to work for most people (and yes it would be nice if it was in the FAQ :-)
You can add the following to your .vimrc file to get Vim to decide it can use color:
if has("terminfo") let &t_Co=8 let &t_Sf="\e[3%p1%dm" let &t_Sb="\e[4%p1%dm" else let &t_Co=8 let &t_Sf="\e[3%dm" let &t_Sb="\e[4%dm" endif
I got the basic information from the :help xterm-color, and then modified it to use 'let' instead of 'set' so that I could use \e for escape, which makes this snippet of code easier to cut and paste into your .vimrc file.
Your mileage may vary, and if your terminal supports more than 8 colors,try modifying the t_Co value accordingly.
Bob Harris
|
|
 | | From: | nospam at geniegate.com | | Subject: | Re: VIM: force color term? | | Date: | Wed, 12 Jan 2005 12:05:43 GMT |
|
|
 | Bob Harris wrote:
> My standard answer. So far it seems to work for most people (and yes it > would be nice if it was in the FAQ :-) > > You can add the following to your .vimrc file to get Vim to decide it > can use color: > > if has("terminfo") > let &t_Co=8 > let &t_Sf="\e[3%p1%dm" > let &t_Sb="\e[4%p1%dm" > else > let &t_Co=8 > let &t_Sf="\e[3%dm" > let &t_Sb="\e[4%dm" > endif > > I got the basic information from the :help xterm-color, and then > modified it to use 'let' instead of 'set' so that I could use \e for > escape, which makes this snippet of code easier to cut and paste into > your .vimrc file. > > Your mileage may vary, and if your terminal supports more than 8 > colors,try modifying the t_Co value accordingly. >
Thanks! that seems to work. :-)
The reason it's messed up is that I frequently use mac OSX with rxvt, console, screen, etc.. It has sometimes has some very strange ideas about terminals, just when you think you've fixed it, something someplace else breaks, so I end up doing TERM=vt102 just to get things to work.
I wrapped it into a function to invoke whenever my terminal is hosed: (There are better ways of doing this, I know..) -------------------------------------------------------- function! s:ColorTerm() if has("terminfo") let &t_Co=8 let &t_Sf="\e[3%p1%dm" let &t_Sb="\e[4%p1%dm" else let &t_Co=8 let &t_Sf="\e[3%dm" let &t_Sb="\e[4%dm" endif endfunction function! s:MonoTerm() if has("terminfo") let &t_Co=0 let &t_Sf="\e[3%p1%dm" let &t_Sb="\e[4%p1%dm" else let &t_Co=0 let &t_Sf="\e[3%dm" let &t_Sb="\e[4%dm" endif endfunction com! ColorTerm call s:ColorTerm() com! MonoTerm call s:MonoTerm() --------------------------------------------------------
Now whenever my terminal doesn't work right, I'll try: :MonoTerm or :ColorTerm
Thanks a bunch!
Jamie -- http://www.geniegate.com Custom web programming guhzo_42@lnubb.pbz (rot13) User Management Solutions
|
|
|