Wednesday, November 28, 2012

Re: autocmd pattern exclusion?

On Nov 28, 2012, at 2:22 PM, Andy Wokula wrote:

> Am 28.11.2012 17:31, schrieb Matt Martini:
>> I have an autocmd that I would like to trigger for all files, except a
>> certain file. Is there a way to write this?
>>
>> I'm thinking something like:
>>
>> autocmd BufReadPost *, !.git/COMMIT_EDITMSG <do stuff>
>
> There is a way:
> :h autocmd-patterns
> and a few lines below:
> :h file-pattern
>
> It is allowed to intermix regexp patterns:
>
> :autocmd BufReadPost *\(.git/COMMIT_EDITMSG\)\@<! <do stuff>
>
> Hints:
> - items starting with `\' are used like in regexp patterns
> - the item to match any character is `?', even within `\(...\)'; the
> dot `.' matches `.' literally here
> - I had to use `\(', because `\%(' gave me an error message
> E55: Unmatched \)
>
> No warranty, HTH,
> Andy
>

Worked like a charm, 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

No comments: