vim 文件类型检测错误

13次阅读

vim开启了文件类型检测,即”filetype on”,并且关闭了vi兼容,”set nocompatible”。按照文档上说法:

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.

其中filetype.vim里关于markdown有下面条目:

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

说明README.md将被视为markdown文件。

可是我打开markdown文件后,却显示为vimwiki文件(vimwiki为我安装的插件),如下图:
vim 文件类型检测错误

这个是什么原因呢?

selfboot

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

selfboot

谢邀 … 我打开 README.md 得到的是正确的结果 … 所以猜测是 vimwiki 覆盖了 vim 的默认配置 …

g:vimwiki_list 里面去掉 .md 文件试试看 ..?

iCode

正文完