【发布时间】:2014-08-04 20:50:59
【问题描述】:
自定义我的 .vimrc 我添加了模板(骨架)文件支持。书中的这个自动命令规则没有做任何事情(没有错误也没有模板):
:autocmd BufNewFile * silent! Or $HOME/.vim/templates/%:e.tpl
这个非 %e 通配符版本产生了一个错误:
:autocmd BufNewFile *.html Or $HOME/.vim/templates/html.tpl
"test.html" [New File]
Error detected while processing BufNewFile Auto commands for "*.html":
E492: Not an editor command: Or $HOME/.vim/templates/html.tpl
在另一篇帖子中,用户orftz (+1) 向我们展示了一种使用串联和双引号的不常见语法(我认为是 PHP)。
:autocmd BufNewFile * :silent! :exec ":0r " . $HOME . "/.vim/templates/" . &ft . ".tpl"
我的 common 版本有什么问题以及为什么其他版本可以工作(我在其他 vim 脚本中没有看到任何这样的引用)。
【问题讨论】:
标签: vim