尝试:
:setf none
或(等效地):
:set ft=
如果要自动执行此操作,则需要配置语法检测。创建一个文件(如果它不存在):vimfiles/after/filetype.vim 或 ~/.vim/after/filetype.vim。在此文件中,添加以下行:
au BufNewFile,BufRead *.markdown set ft=none
或者,从这里下载 markdown 语法(我没有尝试过)并配置:
au BufNewFile,BufRead *.markdown set ft=mkd
了解更多信息:
:help :setf
:help 'filetype'
:help :autocmd
:help BufRead
:help BufNewFile
有关信息,问题的出现是因为.markdown
无法识别扩展名,因此 Vim 会查看内容以尝试确定文件类型。大概你的文件中有一些看起来有点像配置文件的东西,所以它会尽力猜测。猜测是在系统中进行的filetype.vim
,通常在 c:\vim\vim72 或 /usr/share/vim/vim72/filetype.vim (我认为)中,看起来像这样:
" Generic configuration file (check this last, it's just guessing!)
au BufNewFile,BufRead,StdinReadPost *
\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
\ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
\ || getline(4) =~ '^#' || getline(5) =~ '^#') |
\ setf conf |
\ endif
这将检查前五行中的任何一行是否以 a 开头,#
如果是,并且没有匹配其他文件类型,则将文件类型设置为conf
。