让 Vim 识别 XML [英] Getting Vim to recognize XML

查看:23
本文介绍了让 Vim 识别 XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望 Vim 帮助我缩进我的 XML 文件,就像我的 C 代码一样.但是,当我使用

I would like Vim to help me indent my XML files like my C code. However, when I use

gg=G

它只是将所有内容都设置在左侧.我需要指定一个语法吗?XML 被识别为一种语言吗?

It just sets everything to the left. Do I need to designate a syntax? Is XML recognized as a language?

推荐答案

Put

filetype plugin indent on

在你的 .vimrc 中让 Vim 自动将 .xml 文件识别为 xml.你可能需要把

in your .vimrc to have Vim automatically identify .xml files as xml. You might need to put

set nocompatible

在那之前.

如果文件扩展名不是 .xml,你可以使用 xml 使 Vim 威胁它

If the file extension is not .xml, you can make Vim threat it like xml by using

:set filetype=xml

在你这样做之后,Vim 的自动缩进(和语法高亮显示,以及omnicomplete(在 xml 中只是关闭标签,但这仍然是一些东西))将适用于 xml.

After you do that, Vim's autoindention (and syntax highlighting, and omnicomplete (that in xml just closes tags, but that's still something)) will work properly for xml.

这篇关于让 Vim 识别 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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