Wednesday, November 28, 2012

new filetype should extent already existing filetype

Hello list,

at the momemt I dive into gtk development and use vim to write the
code.

To simplify my work i have been thinking about creating a new filetype
called 'c::gtk' that vim should set if a newly created buffer
with ft=c contains

#include <gtk/gtk.h>

Without the constraint 'ft=c' ut seems to be no problem to achieve this
specific goal since vim's help is very detailed about that (see ':h
new-filetype-scripts').

Unfortunately i don't now how i should proceed, so that before
executing the filetype ('c::gtk') specific commands all commands of the
'c'-filetype are executed. My thoughts are mainly based on the concept
of inheritance. Up to now i can't find any vim related information that
says that a filetype can inherit all properties of an already existing
filetype. I would like to know whether vim provides such concept
transferred to filetypes!?

In the case vim can't handle it that way, i would probably create
c/gtk.vim and c.vim in after/ftplugin. Further 'c.vim' would try to
match

#include <gtk/gtk.h>

in the current file. In the case the pattern matches, 'c/gtk.vim' which
contains the gtk specific settings would be executed. This way i
wouldn't touch the filetype.

Probably some of you experts have already achieved something like this.
I would be very thankful if you could outline how you realized it or
any other comment.

Thanks for your time and with best regards

Johannes

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: