LinuxGem
此处为老的 LinuxGem,新版 LinuxGem 请移步 www.linuxgem.org

Vim 的 XML 文档编辑插件——xml.vim

galeki posted @ 2007年11月05日 20:03 in 文档编辑与排版 with tags XML vim , 11321 阅读

Vim 有一个用于编辑 XML 文档的插件 xml.vim 非常好用,下载地址是:

http://www.vim.org/scripts/script.php?script_id=1397

这个插件的安装很简单,将下载的 xml.vim 文件复制到 ~/.vim/ftplugin 目录下,并在该目录下分别建立连接 docbk.vim、xsl.vim、html.vim、xhtml.vim,让它们皆指向 xml.vim。然后重新启动 vim 即可。

如果你使用的是 gvim,且所编辑的文档的扩展名是 ".xml",那么菜单栏会有一个 “xml” 菜单,对那些不愿意输入命令的用户可能会有用。

下面介绍一下 xml.vim 的几个常用功能。

标记的自动闭合

输入前一半标记,会自动添加后一半标记,并把光标放置在标记中间。

譬如,输入:

<para>

vim.xml 会将其闭合为:

<para>|</para>

注:上面代码中出现的 “|” 符号,这里用来表示 vim 中的插入光标。

标记换行+闭合

在输入标记的前一半后,再输入一个 > 符号,会进行换行:标记的前半部分与后半部分各占一行;标记行的中间有一空行,显示插入光标。

譬如,输入:

<para>>

xml.vim 会将其处理为:

<para>
    |
</para>

标记的快速输入

直接输入标记名后面跟随两个分号,即可实现标记的换行+闭合。

譬如,输入:

para;;

可以得到:

<para>
    |
</para>

快速修改标记名

将光标移动到要修改的标记上,在 normal 模式下输入 \c ,这时:如果你用的是 gvim,就会跳出一个对话框,在其文本框中输入新的标记名即可;如果你是在终端中使用 vim,只需要 vim 下面的命令窗口中输入新的标记名即可。

在标记上跳跃

将光标移动到某一标记名上,然后在 normal 模式下摁 % 键,光标就可以在标记的前半部分与后半部分来回跳转。如果当前光标是在标记的括号上,那么它就像 vim 往常那样,在括号的前半部分与后半部分来回跳跃了。

更详细地用法

xml.vim 的详细用法请参考其说明文档,在 vim 的 normal 模式下,输入:

:h xml-plugin

即可打开说明文档。

bucuo 说:
2007年11月06日 07:03 哦也,一直在用
梦流星 说:
2012年8月16日 14:16

这个插件的安装很简单,将下载的 xml.vim 文件复制到 ~/.vim/ftplugin 目录下,并在该目录下分别建立连接 docbk.vim、xsl.vim、html.vim、xhtml.vim,让它们皆指向 xml.vim。然后重新启动 vim 即可。

请问这一步如何实现?我不太会用这个,我是在win7下用gvim的

anonymous 说:
2023年11月13日 02:14

There you can download for free, see the first of these data.  Pest Control Kissimmee

anonymous 说:
2023年11月15日 18:26

It is very good, but look at the information at this address.  Pest Control Orlando

anonymous 说:
2023年11月15日 18:28

Hmm… I interpret blogs on a analogous issue, however i never visited your blog. I added it to populars also i’ll be your faithful primer. Pest Control Oviedo

anonymous 说:
2023年11月28日 17:48

This is awesome work you've done here. I don't state this to a ton of professional, however you merited that. You should take a shot at some of the other subjects I've recommended you before. Pest Control Tampa

anonymous 说:
2024年1月11日 14:52

I invite you to the page where     see how much we have in common. online accountant

anonymous 说:
2024年1月17日 19:59

These things are very important, good think so - I think so too...  تصليح ثلاجات

anonymous 说:
2024年1月17日 20:04

I've proper selected to build a blog, which I hold been deficient to do for a during. Acknowledges for this inform, it's really serviceable! تركيب كاميرات مراقبة الكويت

anonymous 说:
2024年1月17日 20:14

I can give you the address       Here you will learn how to do it correctly. Read and write something good. تصليح طباخات

anonymous 说:
2024年1月17日 20:19

In this case you will begin it is important, it again produces a web site a strong significant internet site: بنشر متنقل

anonymous 说:
2024年1月17日 20:24

In this particular article, you will see a summary, satisfy browse this post. تصليح طبخات المنطقة العاشره

Victoria Willis 说:
2024年1月29日 22:33

It is fine, nonetheless evaluate the information and facts around this correct. Lentoria

Victoria Willis 说:
2024年1月29日 22:42

Hmm… I interpret blogs on a analogous issue, however i never visited your blog. I added it to populars also i’ll be your faithful primer. Lentor Mansion

Victoria Willis 说:
2024年1月29日 22:48

Listed here you'll learn it is important, them offers the link in an helpful webpage: The Giverny Residences

Victoria Willis 说:
2024年1月30日 19:35

I propose merely very good along with reputable data, consequently visualize it: printed tiles

Clay Lowe 说:
2024年2月08日 23:06

CowPokesOnline - Western Wear Stores near me. Shop Western wear Online. We are a destination for your lifestyle, not just a retail store.

Clay Lowe 说:
2024年2月23日 13:04

Such sites are important because they provide a large dose of useful information ...  weed dispensary Maryland

Clay Lowe 说:
2024年2月26日 18:22

Just got my fgf20 screens from screens-people.com and they're fantastic! Crisp display and easy setup. Perfect for my work-from-home setup!


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter