持久性:set语法给定的文件类型? [英] Persistent :set syntax for a given filetype?

查看:71
本文介绍了持久性:set语法给定的文件类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个使用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

应该工作.

这篇关于持久性:set语法给定的文件类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆