4

There is a standard for providing files that may have an unversioned counterpart. That standard consists in suffixing the filename with .dist, so for example phpunit.xml becomes phpunit.xml.dist. How can I tell vim that whenever it sees that suffix, it should remove it when attempting to determine the filetype?

1

1 Answer 1

4

Put this into

~/.vim/ftdetect/dist.vim

autocmd BufNewFile,BufRead ?\+.dist
    \ execute 'doautocmd filetypedetect BufRead' fnameescape(expand('<afile>:r'))

Basically we strip the .dist extension and re-execute the filetype-detection routine. A similar code is used in $VIMRUNTIME/filetype.vim to detect filetype for *.bak, *.old and a few other "generic" extensions. Unfortunately, *.dist isn't found there.

1
  • 1
    Thank you! When I think of all these years I wasted not asking this question…
    – greg0ire
    Aug 27, 2020 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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