0

This question already has an answer here:

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?

marked as duplicate by nobe4, kenorb, statox, EvergreenTree, Gilles Aug 25 '15 at 22:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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 Aug 25 '15 at 22:44
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.