search

Home  >  Q&A  >  body text

vim file type detection error

vim turns on file type detection, that is, "filetype on", and turns off vi compatibility, "set nocompatible". According to the documentation:

Detail: The ":filetype on" command will load one of these files:
Mac $VIMRUNTIME:filetype.vim
Unix $VIMRUNTIME/filetype.vim
This file is a Vim script that defines autocommands for the
BufNewFile and BufRead events. If the file type is not found by the
name, the file $VIMRUNTIME/scripts.vim is used to detect it from the
contents of the file.

There are the following entries about markdown in filetype.vim:

" Markdown
au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,README.md setf markdown

Explanation README.md will be treated as a markdown file.

But after I opened the markdown file, it was displayed as a vimwiki file (the plug-in vimwiki installed for me), as shown below:

What is the reason for this?

phpcn_u1582phpcn_u15822774 days ago1163

reply all(2)I'll reply

  • 黄舟

    黄舟2017-05-16 16:44:11

    The easiest solution to this is to change the default setting of the g:vimwiki_ext2syntax variable in your .vimrc (or Janus could make this the default) as follows:

    let g:vimwiki_ext2syntax = {}

    The default value of g:vimwikiext2syntax = {'.md': 'markdown'}. This setting tells vimwiki to recognize files with a ".md" extension, overriding previous filetype associations. See ":help vimwikiext2syntax".

    vimwiki/markdown conflict

    reply
    0
  • 黄舟

    黄舟2017-05-16 16:44:11

    Thanks for the invitation... I opened README.md and got the correct result... So my guess is that vimwiki has overwritten vim's default configuration...

    Try it in g:vimwiki_list 里面去掉 .md file ..?

    reply
    0
  • Cancelreply