I know that it's not very common, but there are few cases in which I would really like to inherit the configurations for one filetype in another.

Example: whatever I set for sh I would like to inherit in zsh and bash

I know that it might be dangerous, since I won't be able to set any sh specific variable any longer, but in few cases (like this), I don't believe this should be a problem.

For the time being the best way I found it's to use:

runtime! ftplugin/sh.vim

are you aware of anything better?

  • 2
    This might not work in every case, but you can have a buffer with multiple filetypes (I exploit this for github.com/benknoble/wiki-md): set filetype=sh.bash.zsh
    – D. Ben Knoble
    Feb 25 at 21:17
  • Thank you @D.BenKnoble . I believe it's quite doing the job. The only thing I can imagine that it's not covered is the ftdetect itself: if I have custom rules for zsh the wanted behavior would be to extend filetype also for them, but maybe it's just a matter of sorting the commands. Can you point me the reference for multiple filetypes? I cannot find it in the docs...
    – Annibale
    Feb 26 at 7:59
  • 1
    @Annibale See the part under :help 'filetype' that begins "When a dot"
    – Rich
    Feb 26 at 9:10
  • @Rich thank you, I was looking to :help filetype unfortunately...
    – Annibale
    Feb 26 at 11:27
  • @Annibale figuring out how to find things in the :help is an art in and of itself ;)
    – Rich
    Feb 26 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.