Saari Development

Ali Rizvi's Technical Blog as a Professional Software Development Engineer

Vim: Set vim filetype to ruby in a Treetop grammar file

leave a comment »

While writing a syntax parser using ruby treetop library for a work project I discovered the need to use ruby filetype for syntax highlighting etc a file ending in .treetop (treetop uses polyglot to look for and compile the grammar on runtime but the grammar file has to end in .treetop).

Here is a nice getting started tutorial for treetop: http://po-ru.com/diary/getting-started-with-treetop/

I could have used some configuration in my .vimrc file to associate this file extension with ruby filetype but I want to try the embedded configuration which I have seen other used but never used myself.

After some search I found the reference article below and was by just adding the following file in the .treetop file I was able to desired functionality:

# vim:filetype=ruby

Ref:Embedding vim Settings in the File You’re Editing

Advertisements

Written by imsaar

June 7, 2010 at 4:21 pm

Posted in editor, vim

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: