vim 文件类型检测错误

【字号: 作者:雯心浏览:34日期:2023-07-26

问题描述

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

Detail: The ':filetype on' command will load one of these files:Mac $VIMRUNTIME:filetype.vimUnix $VIMRUNTIME/filetype.vimThis file is a Vim script that defines autocommands for theBufNewFile and BufRead events. If the file type is not found by thename, the file $VIMRUNTIME/scripts.vim is used to detect it from thecontents of the file.

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

' Markdownau BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,README.md setf markdown

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

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

这个是什么原因呢?

问题解答

回答1:

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

回答2:

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

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

相关文章: