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?

  • 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]} – Gilles 'SO- stop being evil' Aug 25 '15 at 22:44

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.