vim中的多种文件类型 [英] Multiple file types in vim

查看:34
本文介绍了vim中的多种文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,当我处理 PHP 文件时,默认文件类型是 php.这是有道理的,但是当该 PHP 文件也有 HTML 时,文件类型仍然只是 php.对于某些插件,这意味着我获得了该插件的 PHP 功能,但错过了 HTML 功能.发生这种情况的更具体情况是我的代码段插件.当我编辑 php 文件时,我得到的是 php 片段而不是 html 片段.

When I am working on a PHP file for example the default filetype is php. This makes sense, however when that PHP file has HTML as well the filetype is still only php. For some plugins that means that I get the PHP functionality for that plugin, but miss out on the HTML functionality. A more specific situation where this happens is with my snippet plugin. I get php snippets and not html snippets when I am editing a php file.

对此的可能解决方案(我显然不喜欢,因此我发布了这个问题)是:

Possible solutions to this (which I obviously don't like, hence my posting this question) are:

  1. 添加映射以在我编辑文件的不同部分时在不同文件类型之间切换.
  2. 更新我的 php 代码段文件以包含 html 代码段(虽然这适用于上面的示例,但不能解决根本问题).

那么,有没有办法在 vim 中同时使用多种文件类型编辑文件?

为了将来参考,我正在谈论的特定插件称为 snipMate.http://www.vim.org/scripts/script.php?script_id=2540

For future reference the specific plugin that I am talking about is called snipMate. http://www.vim.org/scripts/script.php?script_id=2540

推荐答案

您可以指定同时使用多种文件类型.例如:

You can specify to use multiple filetypes at the same time. For example:

:setfiletype html.php

但是大多数文件类型插件和语法文件不是为这种情况设计的.另见:help '文件类型'

But most of filetype plugings and syntax files are not designed for such cases. See also :help 'filetype'

这篇关于vim中的多种文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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