vim "syntax on" does not work

opensuse, vi, vim

Solution

When you edit the file, are you using

vim filename

This can matter. In some server configurations, if you do `vi filename` you get vim, but it's a very stripped down version of vim that is very much like the original vi (which does not, among other things, do syntax coloring). On a system configured in this way, if you instead type `vim filename`, you get the full featured vim.

I just worked through this with a person who was on a server that had the vim-minimal package installed as well as another vim package. I suspect (but did not verify that) the `vim-minimal` package installed its executable as `/bin/vi`.

The difference was very clear when you looked at the actual files (i.e. `ls -l /bin/vi` vs `ls -l /usr/bin/vim`)--one was about ten times the size. Both of them were actually vim, same version number and everything, but the /bin/vi one was compiled with very few features enabled.

To make it even more confusing:

vi existing.pl

opened the .pl file, gave no syntax coloring

vi [enter]

gave the vim splash screen, and from there

:e existing.pl

opened the file with syntax coloring on.

A comment from Jan Wilamowski suggests checking by doing:

vi --version

If that shows that the syntax feature was not compiled in, try

vim --version

and see if it is compiled in there.

Problem

Here is my `.vimrc` ``` 1 syntax on 2 set ts=4 3 set number 4 set smartindent 5 set shiftwidth=4 ``` However, I tried to edit `HelloWorld.java` and `HelloWorld.c`. Both have pure regular black font. No any highlighting! I also tried `:syntax on` after the vim is open, but no luck. ``` \>vim -version VIM - Vi IMproved 7.3 (2010 Aug 15) \>cat /etc/*-release openSUSE 11.4 (x86_64) VERSION = 11.4 CODENAME = Celadon ```

Original source