Sunday, February 04, 2007

Vim Syntax Highlighting

I've been trying to understand how to get the syntax highlighting to work. I know that it works because when I create files like index.html or when I edit files like .bashrc or .bash_profile, there will be syntax highlighting. However, when I create a file for example 'fluxbox' in order to enter my startup script there, no colours appear even with setting ":syntax on". I was puzzled about that. After looking for a very long time, I finally found out:

1. The type of highlighting will depend on the extension of the file, which I have created. For example, if I create index.html, the colors will appear automatically. If the file was just named index, there will not be any automatic syntax highlighting even with html codes in it. I had to go through a few tutorials, before I found one which actually mention this!

2. You can force syntax highlighting for files with odd, different or no extension.
set: syntax=sh
set: syntax=html
set: syntax=php

and so on

3. You can check for the supported languages in /usr/share/vim/vim70/ftplugin

No comments: