如何制作一个扩展名为.pt的文件,并突出显示xml语法和vim的插件snipmate加载pt.snippets? [英] How to make a file with .pt extension, with xml syntax highlighting and vim's plugin snipmate load pt.snippets?

查看:126
本文介绍了如何制作一个扩展名为.pt的文件,并突出显示xml语法和vim的插件snipmate加载pt.snippets?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.vimrc中包含以下内容:

au BufNewFile,BufRead *.pt set filetype=xml

这是必需的,因为尽管我正在编辑扩展名为*.pt的文件,但它确实是一个有效的xml文件:像这样设置文件类型,可以使语法高亮显示.

This is needed because although I'm editing a file with *.pt extension, it's indeed a valid xml file: setting the filetype like this I can have syntax highlighting.

我正在使用 vim的片段插件,并试图由于这些文件是Zope页面模板(带有TAL的ZPT),因此可以根据特定需求创建pt.snippets.

I'm using vim's snipmate plugin, and tried to create pt.snippets to specific needs since these files are Zope Page Templates (ZPT with TAL).

现在,我有一个问题:我不想在xml.snippets中创建这些代码段,因为它们并不是真正的通用XML代码段,但是我的*.pt文件设置为xml,所以当我定义自己的代码段时除非我在vim上的pt文件上运行:set filetype=pt,否则不会加载它们的pt代码段-但随后我丢失了语法高亮显示.

Now, I have a problem: I don't want to create these snippets in xml.snippets, since they aren't really generic xml snippets, but my *.pt files are set to xml, so when I define my pt snippets they aren't loaded unless I run :set filetype=pt on my pt file on vim - but then I lose syntax highlighting.

我希望能够拥有一个突出显示xml语法的pt文件,以便能够从snipmate加载pt.snippets文件.我该怎么办?

I would like to be able to have a pt file, with xml syntax highlighting, to be able to load a pt.snippets file from snipmate. How can I do it?

(我想避免将我的代码片段放在通用的代码片段文件中,我希望它仅出现在pt.snippets中,以便于维护.)

(I would like to avoid putting my snippets in a generic snippet file, I would like it to be present only in pt.snippets to be easier to maintain.)

推荐答案

Snipmate允许使用点分文件类型"语法,请尝试:

Snipmate allows for dotted 'filetype' syntax, try:

au BufNewFile,BufRead * .pt设置filetype = xml.pt

au BufNewFile,BufRead *.pt set filetype=xml.pt

这篇关于如何制作一个扩展名为.pt的文件,并突出显示xml语法和vim的插件snipmate加载pt.snippets?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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