2

在我的 .vimrc 我添加了这个,

autocmd BufNewFile,BufRead *.markdown setfiletype octopress

但这似乎不起作用,因为在我打开 xxx.markdown 文件并输入命令后setfiletype octopress一切正常。

这是我完整的 .vimrc

set nocompatible
syntax on
filetype off
colorscheme desert
set nu
set mouse=a
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
filetype plugin indent on    

Bundle 'vim-octopress'
autocmd FileType markdown setfiletype octopress

希望有人可以帮助我并告诉我如何调试这个东西......

4

3 回答 3

5

我没有看到这个:

autocmd BufNewFile,BufRead *.markdown setfiletype octopress

我只在最后看到这个:

autocmd FileType markdown setfiletype octopress

我认为修复它会解决你的问题。

更新:

还有几件事要考虑。首先,Markdown-syntax 插件将文件类型设置为mkd,而不是markdown. 这似乎也无法正常工作:

autocmd FileType mkd setfiletype octopress

但这确实:

au FileType mkd set filetype=octopress

......现在这是有道理的。 setfiletype如果已设置文件类型,则不会设置文件类型。由于它已经被标记为 type mkd,它没有被更新为新的文件类型。

于 2013-06-28T02:19:21.757 回答
0

这是因为setfiletype ... but only if not done yet in a sequence of (nested) autocommands.

关于 setfiletype 函数的文档

于 2013-06-28T03:02:02.453 回答
0
filetype plugin on
filetype indent on
au FileType htm,html,php,css setl ts=2 sw=2 sts=2 et
于 2018-09-24T15:18:07.410 回答