vim enable font color

On vi how to enable a font colors while editing a shell script or a c/c++ program. I am using vim 7.1.266 on opensuse 11.0.

In ~/.vimrc put

syntax enable

or from inside Vim do

:syn on

I cannot find .vimrc in my home directory on suse. There is another file called .viminfo but it just gives the information on vim.

:syn on
It did not work for me when I tested it on vi while a shell script is open.

Thanks

I don’t know if you’re using vi in compatible mode, or if that even has syntax highlighting. Try creating a ~/.vimrc with the following two lines:

set nocompatible
syntax enable

reopen vi (or vim) and see what happens.

The default install of openSUSE does not come with vim-data installed. vim-data contains all the important plugins for filetype detection as well as syntax files. Install it from the repo.

In case its already installed, see the output of the command

:set filetype

If the output is just a

filetype =

, then your filetype detection is off. In this case, I would suggest you see the following vim documentation:
Vim documentation: syntax

In my case, I had no vim-data installed, which was creating all the issues.

I think it’s actually syntax on.

At any rate, I think by default it’s commented out. Look for syntax on in /etc/vimrc. If the line begins with a ‘"’ remove it to uncomment it.

:syn on and :syntax enable are one and the same thing.

Installing “vim-data” did the trick for me, thanks :slight_smile:

Edited now