vi syntax coloring

loves_the_IIsi

Registered
Hi all,

Does anyone know how to get syntax highlighting in vi? I've found a few descriptions of how to do it, but I can't seem to get it working. A couple weeks ago it randomly started showing colors, and then a few days ago it didn't do that anymore. What the heck did I do that would have changed it?

thanks :)
 
loves_the_IIsi said:
Hi all,

Does anyone know how to get syntax highlighting in vi? I've found a few descriptions of how to do it, but I can't seem to get it working. A couple weeks ago it randomly started showing colors, and then a few days ago it didn't do that anymore. What the heck did I do that would have changed it?

thanks :)

Hi - do you have a ~/.vimrc file? Is not, create it, and make sure it contains the line:

Code:
:sy enable

Then launch vi again and see what ya get. I also have my TERM env variable set to xterm-color, although my foggy brain seems to recollect that's to enable colour output with $LS_OPTIONS....
 
hmm, I didn't have that file, but I did add it and that line, but that didn't seem to work either. I also have my TERM set to xterm-color, which I thought had something to do with it, but I guess maybe not.
 
This should be a better solution :
in your .vimrc file write these lines

Code:
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

I've copied this from my file (made from an example of Bram Moolenaar)
 
Back
Top