我正在开发一个使用 Twig 的 Symfony2 项目,文件类型是 myfile.html.twig
.Vim 不会自动检测语法高亮,因此不应用.我可以在打开文件后使用 :set syntax=HTML
但是在文件之间跳转时会很痛苦.
I'm working on a Symfony2 project which uses Twig, and the filetypes are myfile.html.twig
. Vim doesn't automatically detect the syntax highlighting and so applies none. I can use :set syntax=HTML
after I've opened the file but this is a pain when jumping between files.
有没有办法在 vim 中为特定文件类型持久设置语法突出显示?
Is there a way to persistently set the syntax highlighting for a specific file type in vim?
你可以使用 autocmd
来完成,即:
You can use autocmd
to accomplish that, i.e.:
augroup twig_ft
au!
autocmd BufNewFile,BufRead *.html.twig set syntax=html
augroup END
应该可以.