sponsor Vim development Vim logo Vim Book Ad

basic Tip #635: getting colors to work on solaris

 tip karma   Rating 128/47, Viewed by 8565 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   January 14, 2004 14:24      complexity:   basic
author:   Brad Lhotsky      as of Vim:   5.7

You need to get the latest ncurses package available at http://www.sunfreeware.com/ and then configure with this option:
--with-tlib=ncurses

This will link to ncurses which fully supports the color codes.  Then make sure your display is exported as a  color capable terminal.

 rate this tip  Life Changing Helpful Unfulfilling 

<< To view all colours available to gvim | Adding Vim to MS-Windows File Explorer Menu >>

Additional Notes

[email protected], January 22, 2004 23:54
I tried this in sun solaris 2.8.. but didn't work out.  
I installed ncurses from the site mentioned and of no use...
-Prem
[email protected], January 23, 2004 20:52
I tried type in the line as VIM command, it return error: "E492: Not an editor command: --with-tlib=ncuerses."
And it dosen't work either,  if I put it in my .vimrc file.
Someone know anything about this, please help!!!

ipkiss _at_ via.ecp.fr, January 29, 2004 7:18
This tip didn't work for me either, but i found another solution: setting the TERM environment variable to "sun-color" did the trick. What's more, it worked only when i did NOT compile with --with-tlib=ncurses (letting it to the default automatic detection) because with it vim said my TERM was unknown :-)
Brad Lhotsky, January 29, 2004 8:18
You also need to setup ld to search /usr/local/lib.  To do this see man crle.  Add that in, make distclean, reconfigure, and build..   Note: This is NOT a runtime (command line/ vimrc) tip, its a compilation tip.
[email protected], February 9, 2004 2:10
Maybe you should "export TERM=xterm-color" in addition to "configure with this option: --with-tlib=ncurses ".
It works  well on my box.
[email protected], February 15, 2004 21:16
Here's what works on my Solaris 8/9 boxes:
(I lifted this off of somewhere and possibly refined it, but I have no idea where).

:if &term; =~ "xterm"
:  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
:endif
[email protected], March 12, 2004 11:40
With Solaris 9 Intel x86 edition, after a normal installation , plus the package ncurses and vim
for Solaris 9 x86 installed
You just need to create a $HOME/.vimrc with:
syntax on

In this case you will get colorised syntax in vim, called from a dtterm
On a native xterm you will not get color, because this is a black and white xterm.

If you install the binaries and lib of XfreeOrg_XFREE86-4.1.0, (package for Solaris Intel from
ftp://ftp.xfree86.org/pub/XFree86/4.4.0/binaries/Solaris-9/) you will get an xterm with color like
under linux.
Don't try to install all the packages in particular the XFree Driver must be the one
from Sun, like SUN_XFREE86-4.0.3 or SUN_XFREE86-4.2.0 which include package to install with
pgdadd, and found in xf86_drv_port_bin_403_2.tar.gz or xf86_drv_port_bin_420_1.tar.gz from:
http://developers.sun.com/solaris/developer/support/driver/tools/video/video-index.html --> Download Porting Kit (you will have to register , but its free, before download). Any way these packages are not required if the native Solaris X driver is fine for your card.

From the ftp.xfree86.org/pub archive, just extract the tarball: Xbin.tgz Xdoc.tgz Xlib.tgz Xman.tgz
for example, under a new created directory /usr/X11R6 if it doesn't exist (created by SUN_XFREE86 when installed), and put /usr/X11R6/bin in the PATH , and /usr/X11R6/lib in LD_LIBRARY_PATH, added in /etc/profile for example.
Then if you use vim in a /usr/X11R6/bin/xterm, you have also to set TERM=xterm-color, then vim works also as fine as in dtterm; unfortunately,  other command like less will complain about bad implementation because xterm-color doesn't exist in /usr/share/lib/terminfo/x; correct the problem by copying in this directory the xterm-color f from linux machine (in /usr/share/terminfo/x)
Anonymous, April 6, 2004 21:55
export TERM=xtermc
that is what worked for me. Many of the systems at this place are still solaris 2.6 though, so I don't know whether this makes a difference, I have got to the 9 systems yet.
[email protected], May 10, 2004 14:06
'xtermc' worked for me as well, connecting using putty to a solaris 5.7 system.  In my case, it seems clear that vim had already been installed using ncurses, but the terminfo was outdated, and the xterm entry doesnt include color information or something.  The net result for me was bold and underlined text, but no real colors.
There is no 'xtermc' in the termcap, which could conceivably cause problems for other (less important) shell applications.
Dave <[email protected]>, May 24, 2004 14:28
Three cheers for Anonymous...

With Putty, set the "Terminal-type string" setting in the "Connection" category to "xtermc".

Save your settings, log in, and enjoy the view.
Anonymous, June 2, 2004 4:32
I tried this :
PuTTY with Terminal-type string to xtermc
TERM to xtermc

and... vim is now working with colours.. But... arrows doesn't work anymore with Midnight Commander...  
An idea ?
Anonymous, July 20, 2004 3:51
In Application keypad settings section in the Keyboard-Config in PuTTY:
do not check Application cursor keys totally disabled
check Initial state of cursor keys: Application
do bot chech Application keypad keys totally disabled
check Initial state of numeric keypad to Application

safe this and enjoy... Well, at least this works for me
Anonymous, July 25, 2004 21:48
The effects of terminal type strings in ncurses (and more) are defined by a very dense configuration that is part of the "terminfo" system, and "termcap" system in some other programs.   I think it's probably too far outside the scope of this forum, but researching that should serve you well (also i dont know enough about it to say anything useful).  Be sure not to miss http://www.catb.org/~esr/terminfo/ - could be a valuable resource if you do give it a go.
Anonymous, November 3, 2004 11:15
solaris 9 - try "TERM=dtterm; export TERM" in an xterm window ... seems to work also
Anonymous, January 11, 2005 4:35
I confirm, 'export TERM=xtermc' enables colors on solaris 2.8 (without --with-tlib=ncurses compile option), but does not work on 2.6 system
[email protected], September 11, 2005 10:43
'xtermc' worked for me on Solaris 10 (as did 'sun-color', but that one limited my view to 60 rows).
Anonymous, March 9, 2006 0:43
export TERM=xtermc worked for me in Solaris 5.8
[email protected], March 23, 2006 20:21
yhatzee!

TERM=xtermc!
[email protected], April 7, 2006 11:44
I would like to thank the guy at the top of this post, I am on a SUN machine as well and have tried everything in this list, but finally I saw a post that said set my TERM to sun-color so I went to my .vimrc and places a nice litte

set term=sun-color
syntax on

and it works like a charm! thanks

~Zjoia
[email protected], May 1, 2006 19:00
set term=xtermc
syntax on

worked like a charm on x86 Solaris 10....many thanks
[email protected], May 8, 2006 3:18
You can also set in your ~/.profile in Solaris 8 the following

export TERM=ansi

then within your ~/.vimrc

syntax on
set nocp incsearch
set cinoptions=:0,p0,t0
set cinwords=if,else,while,do,for,switch,case,def
set formatoptions=tcqr
set cindent
set ruler

that should work for most installs with the SunFreeware packages.
[email protected], May 29, 2006 14:27
Having trouble installing Vim 7.0 on Solaris 10 with color support.

A previous installation of Vim was installed as the sunfreeware package to /usr/sfw/bin/.  Color worked just fine.  The Ncurses library is also installed via sunfreeware and resides in /usr/sfw/lib/.  The load library path shouldn't be a problem:

$ crle
Configuration file [version 4]: /var/ld/ld.config  
  Default Library Path (ELF):   /lib:/usr/lib:/usr/local/lib:/opt/sfw/lib:/usr/sfw/lib
  Trusted Directories (ELF):    /lib/secure:/usr/lib/secure  (system default)

Command line:
  crle -c /var/ld/ld.config -l /lib:/usr/lib:/usr/local/lib:/opt/sfw/lib:/usr/sfw/lib

Yet when running configure this line pops up:
/tmp/vim70$ ./configure | grep ncurses
checking for tgetent in -lncurses... (cached) no

Any ideas on how to get color properly enabled?
[email protected], June 1, 2006 13:30
The resolution was to link to ncurses and to also remove the linking to termlib.  They seem to coexist poorly.
[email protected], June 15, 2006 19:07

Free Luke Skywalker from the Evil grips of the Empire.
Anonymous_2, July 19, 2006 23:03
Hey... exporting TERM to xtermc worked for me as well! I am using a sol 8 box.

Anonymous rocks!!  Thanks friend.

--
thanks and regards,
Anonymous_2
[email protected], October 6, 2006 6:18
I just built vim 7.0 with no special options or libs and set "export TERM=xterm-color" to get color.
[email protected], October 6, 2006 6:22
TERM=xterm-color works better for me than TERM=xtermc.  Both give color but xtermc produces some artifacts when exiting vim.
[email protected], November 21, 2006 22:59
Awesome Man!.......This anonymous guy is superb...
I'm working on putty and solaris9 and setting environment
variable TERM=dtterm and syntax on in .vimrc work for me..

Thanks...............
null at mailnull dot com, January 19, 2007 9:34
both dtterm and xterm works fine from me in Solaris 10
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Sponsored by Web Concept Group Inc. SourceForge.net Logo