Loading ...
Sorry, an error occurred while loading the content.

new filetype should extent already existing filetype

Expand Messages
  • Johannes Deutsch
    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
    Message 1 of 3 , Nov 28, 2012
    • 0 Attachment
      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
    • Andy Wokula
      ... = create filetype scripts for gtk , then use a modeline in your source files: /* vim:set ft=c.gtk: */ ... This will load ftplugin and syntax scripts for
      Message 2 of 3 , Nov 28, 2012
      • 0 Attachment
        Am 28.11.2012 11:04, schrieb Johannes Deutsch:
        > 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.

        It's a less esoteric demand than you think:
        :h 'ft

        => create filetype scripts for "gtk", then use a modeline in your source
        files:
        /* vim:set ft=c.gtk: */

        :h modeline

        This will load ftplugin and syntax scripts for both C and gtk.

        --
        Andy

        --
        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
      • Johannes Deutsch
        On Wed, 28 Nov 2012 14:28:47 +0100 ... That s exactly what i was looking for! Thanks a lot for your answer... best regards -- You received this message from
        Message 3 of 3 , Nov 28, 2012
        • 0 Attachment
          On Wed, 28 Nov 2012 14:28:47 +0100
          Andy Wokula <anwoku@...> wrote:

          > Am 28.11.2012 11:04, schrieb Johannes Deutsch:
          > > 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.
          >
          > It's a less esoteric demand than you think:
          > :h 'ft
          >
          > => create filetype scripts for "gtk", then use a modeline in your
          > source files:
          > /* vim:set ft=c.gtk: */
          >
          > :h modeline
          >
          > This will load ftplugin and syntax scripts for both C and gtk.
          >

          That's exactly what i was looking for! Thanks a lot for your answer...

          best regards

          --
          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
        Your message has been successfully submitted and would be delivered to recipients shortly.