Vim, by default, opens all .md files as "modula2" code. I have never heard of modula2, nor do I plan to use it.
How can I tell vim to always treat foo.md
as Markdown (as if I had typed :set ft=markdown
)?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityIn the file filetype.vim
that is shipped with your distribution you will find a line that looks probably similar to this (on my machine it lives at /usr/share/vim/vim74
) :
au BufNewFile,BufRead *.md,*.m2,*.mi setf modula2
Now, this tells vim to set the filetype as modula2 if your file has such an ending.
To override this behaviour you can put a line like this in your own .vimrc
(Taken from the Archlinux filetype.vim) :
au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md set ft=markdown
Edit:
I previously had setf
as the function to be called, but it seems to be a reserved function for the filetype.vim
file.
I currently have this line as an ugly hack in my .vimrc:
autocmd BufRead *.md set ft=markdown
I'm still wondering if there's a better way, though.
autocmd
after filetype on
(with or without the plugin
/ indent
flags), I would guess the results are better. Not tested, just speculation.
.md
is being seen as markdown*.md
files are recognized as Markdown instead of modula2 by default.