My default indent width settings (4 spaces) are not used for markdown files. Whenever I open a markdown file it is indented using 2 spaces.

Here are my default indent width settings. In my .vim/vimrc I have

set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab

almost at the end. I have no markdown plugins installed.

I have a .vim/ftdetect/markdown.vim

au BufNewFile,BufReadPost *.md set filetype=markdown

and a .vim/ftplugin/markdown.vim

let g:markdown_fenced_languages = ['python', 'bash=sh', 'shell=sh', 'c', 'html', 'css', 'javascript', 'js=javascript', 'json=javascript' ]
let g:markdown_syntax_conceal = 0
let g:markdown_minlines = 100
setlocal spell

Also adding

set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab

to .vim/ftplugin/markdown.vim does not change the situation.

Note, the filetype is properly recognized. Manually setting it after the file is opened worked.

  • Why are my settings not applied?
  • How to debug this?

1 Answer 1


If you open :e $VIMRUNTIME/ftplugin/markdown.vim you will find that it loads ALL filetype plugins for html

runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim

Command runtime! with an exclamation mark will source all matched files found in your runtime path, including your local .vim/ftplugin/html.vim.

To properly override any settings you have to put them into .vim/after/ftplugin/markdown.vim file -- it will be sourced AFTER $VIMRUNTIME/ftplugin/markdown.vim and .vim/ftplugin/markdown.vim (and thus after your html included filetypes).

Your Answer

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

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