Reputation: 14270
I have a file ~/.vim/ftplug/markdown.vim that contains these directives:
setlocal tabstop=4
setlocal shiftwidth=4
setlocal softtabstop=4
setlocal expandtab
I also have an html.vim file that contains these directives:
setlocal tabstop=2
setlocal shiftwidth=2
setlocal softtabstop=2
setlocal expandtab
I'm finding that whenever I edit a .md file, I can do ":set sw=?" and see that it's set to 2, not 4, as I would expect. This holds true for the other settings as well. I suspect that Vim is also reading my html.vim file when I open a markdown file. Is that what's happening? And if it is, is there any way I can tell Vim to just read the markdown.vim file and ignore the html.vim file whenever I open a .md file?
Upvotes: 1
Views: 84
Reputation: 172590
Yes, the markdown filetype plugin script ($VIMRUNTIME/ftplugin/markdown.vim
) sources (kind of "inherits from") the html filetype, presumably because Markdown allows inline HTML.
In order to customize stuff like indent settings, put your commands into the after directory; i.e. ~/.vim/after/ftplugin/markdown.vim
. As these follow later in the 'runtimepath'
, they are read last, and therefore can override the default settings.
Upvotes: 1