Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vim Syntax Highlighting

Status
Not open for further replies.

CaKiwi

Programmer
Apr 8, 2001
1,294
US
I am trying to create a very simple syntax highlighting file for vim. Highlighting is working for standard files such as .vim files

Example file t.pp

LN1 = LINE/0,0,2,0 $$ COMMENT
LN2 = LINE/PARLEL,LN1,XLARGE,1 % COMMENT
$$ COMMENT
% COMMENT

I want the word LINE to be one color and the words PARLEL and XLARGE to be another color. There are more words of each type which I want to be able to add. Everything after $$ or % is a comment which could be a third color.

Any help greatly appreciated.

CaKiwi
 
Have a look at /usr/share/vim/vim72/syntax/README.TXT (or the equivalent for your version of vim), which gives you some clues about where to start.

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Thanks for the response, Annihilannic.

I think the piece I'm missing is how to get vim to recognize a new file type. Fortran has a few of the same key words (if, endif, do, etc) so I copied the fortran syntax file as a pp syntax file but nothing was hightlighted.

Any help greatly appreciated.

CaKiwi
 
See :help mysyntaxfile in VIM for the steps you need to follow. This leads on to :help myfiletypefile which tells you how to go about recognising a new file type.

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
The part I was missing was to put my file type in the filetype.vim file (in /usr/share/vim/vimcurrent on my system). I found it by searching for f77 in the vim directory. It must be mentioned in the doc somewhere, but I didn't find it, although reading doc is not my forte.

CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top