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

How can I write an autocmd-pattern that _excludes_ a single filetype?

Expand Messages
  • Ivan
    I m trying to write an autocommand that triggers for all filetypes except netrw . I have a few candidate patterns that seem to work at the command line, but I
    Message 1 of 3 , Jan 6, 2014
    • 0 Attachment
      I'm trying to write an autocommand that triggers for all filetypes except "netrw". I have a few candidate patterns that seem to work at the command line, but I can't seem to translate them into working patterns for the autocommand.

      The command line versions:
      ^\(\(.*netrw.*\)\@!.\)*$
      ^\(.*netrw\)\@!.*$
      \<\(.*netrw\)\@!.*\>

      :h file-pattern describes the syntax for matching filenames, so I tried translating the above patterns assuming that it matches filetypes the same way. But nothing I've tried works so far.

      Is this possible?

      --
      --
      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

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Ben Fritz
      ... The easier way to exclude a single filetype is to check the value of the filetype option in a globally matching autocmd: autocmd FileType * if
      Message 2 of 3 , Jan 7, 2014
      • 0 Attachment
        On Tuesday, January 7, 2014 1:07:34 AM UTC-6, Ivan wrote:
        > I'm trying to write an autocommand that triggers for all filetypes except "netrw". I have a few candidate patterns that seem to work at the command line, but I can't seem to translate them into working patterns for the autocommand.
        >
        > The command line versions:
        > ^\(\(.*netrw.*\)\@!.\)*$
        > ^\(.*netrw\)\@!.*$
        > \<\(.*netrw\)\@!.*\>
        >
        > :h file-pattern describes the syntax for matching filenames, so I tried translating the above patterns assuming that it matches filetypes the same way. But nothing I've tried works so far.
        >
        > Is this possible?

        The easier way to exclude a single filetype is to check the value of the 'filetype' option in a globally matching autocmd:

        autocmd FileType * if &filetype!=#'netrw' | call DoSomething() | endif

        --
        --
        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

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Ivan
        ... I think you re right. Thanks! -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying
        Message 3 of 3 , Jan 7, 2014
        • 0 Attachment
          On Tuesday, January 7, 2014 11:04:24 AM UTC-5, Ben Fritz wrote:
          > The easier way to exclude a single filetype is to check the value of the 'filetype' option in a globally matching autocmd:
          >
          > autocmd FileType * if &filetype!=#'netrw' | call DoSomething() | endif

          I think you're right. Thanks!

          --
          --
          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

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        Your message has been successfully submitted and would be delivered to recipients shortly.