X

News, tips, partners, and perspectives for the Oracle Solaris operating system

vi colors

Guest Author

When I edit a text file in vi, I find it much easier to read if the syntax is color highlighted. There are 2 steps to enabling this. First, add an alias for vi (or vim) to your ~/.bashrc file as follows:

#
# Enable color support for vi
#
alias vi='TERM=xtermc vim'

You can read the gory details about why this needs to be done in bug 1641 - xterm terminfo entry doesn't support color.

You also need to tell vi to use syntax coloring. Adding the following to your ~/.vimrc file (create one if it doesn't yet exist):

syntax on

Much nicer:



Join the discussion

Comments ( 4 )
  • shmerl Thursday, October 8, 2009

    Yes, it works, but unfortunately it messes up Midnight Commander, and I have to set it up back to "xterm" any time I need to call mc.


  • Brian Leonard Thursday, October 8, 2009

    OK. The updated solution using an alias should solve that problem.


  • guest Monday, October 19, 2009

    nice


  • Carlo Hamalainen Tuesday, March 2, 2010

    Great, thanks.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha