vim 文件类型检测错误
phpcn_u1582
phpcn_u1582 2017-05-16 16:42:11
[PhpStudy讨论组]

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为我安装的插件),如下图:

这个是什么原因呢?

phpcn_u1582
phpcn_u1582

全部回复(2)
黄舟

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

黄舟

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

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号