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
    I know this isn't exactly what you asked, but does this answer your question? How to find what is causing the command line height to be changed after opening / closing a tab? Commented Oct 2, 2020 at 13:59
  • 1
    :verbose set tabstop? softtabstop? shiftwidth? expandtab?
    – Maxim Kim
    Commented Oct 2, 2020 at 14:14
  • pls explain how exactly default settings are not used
    – Maxim Kim
    Commented Oct 2, 2020 at 14:16
  • @MaximKim your posted command shows that the wrong settings come from my .vim/ftplugin/html.vim. This file only holds the 4 commands.
    – Stefan
    Commented Oct 2, 2020 at 15:10
  • @Stefan markdown sources html, so double-check that. In general, you want to use .vim/after/ftplugin and setlocal
    – D. Ben Knoble
    Commented Oct 2, 2020 at 15:34

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 you have read our privacy policy.

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