Tuesday, January 7, 2014

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

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@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: