0

I want to to run run an autocmd for all but tex files, i figured out this solution:

autocmd BufWritePre *.[^t][^e][^x] :Autoformat 

but is kind of ugly, because of this repeated [^..] pattern. Is there a nicer wy?

1
  • It's not only ugly, but wrong: it won't trigger on e.g. foo.txt. The correct negation of *.tex is {*[^.]???,*[^t]??,*[^e]?,*[^x]} Commented Aug 25, 2015 at 22:44

1 Answer 1

4

The usual way to do this is to call a function for each file and in the function check, return if the file extension is of a certain type. I have explained similar alternativeshere

The disadvantage of your example is, your pattern won't trigger for files like foobar.txt (first t will be excluded), files without extensions, foobar.diff (extension too long).

Not the answer you're looking for? Browse other questions tagged or ask your own question.