matchtagalways


Ⅰ. 插件描述

A Vim plugin that always highlights the enclosing html/xml tags

Ⅱ. 基本信息

创建日期:  2012-09-08
使用用户:  1198
Github星:  487
插件作者:  Val Markovic

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'valloric/matchtagalways'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'valloric/matchtagalways'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'valloric/matchtagalways'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/valloric/matchtagalways

Ⅳ. 文档说明

# Always highlight enclosing tags

Build Status

The MatchTagAlways.vim (MTA) plug-in for the Vim text editor always
highlights the XML/HTML tags that enclose your cursor location. It's probably
easiest to describe with a screenshot:

MatchTagAlways screen shot

It even works with HTML templating languages like Jinja or HTML5 use-cases
like unclosed tags. It's pretty smart and should do the right thing in most

  1. If it doesn't, report the problem on the issue tracker!

Installation

Use Vundle to install the plugin. You are using Vundle to manage
your Vim plugins, right? Pathogen works fine too (but I recommend
Vundle).

Note that the plugin requires that your copy of Vim is compiled with Python

  1. You can check for this with :echo has('python') in Vim. If the output
  2. 1, then you have Python support.

After installation you should be done. The plugin should be plug & play. It will
automatically turn itself on for HTML, XML and a few other HTML-like filetypes.
You can also explicitly turn it on for other filetypes too (more details in the
Options section).

Options

All options have reasonable defaults so if the plug-in works after installation
you don't need to change any options. These options can be configured in your
[vimrc script] [vimrc] by including a line like this:

let g:mta_use_matchparen_group = 1

Note that after changing an option in your [vimrc script] [vimrc] you have to
restart Vim for the changes to take effect.

The g:mta_filetypes option

This option holds all the filetypes for which this plugin will try to find and
highlight enclosing tags. It's a Vim dictionary with keys being Vim filetypes.
The values set for those keys don't matter and are not checked, the only thing
that matters is that a key is present in the dictionary (VimL has no sets).

You can find out what the current file's filetype is in Vim with :set ft?.
Don't forget that question mark at the end!

Default: { 'html' : 1, 'xhtml' : 1, 'xml' : 1, 'jinja' : 1 }

let g:mta_filetypes = {
    \ 'html' : 1,
    \ 'xhtml' : 1,
    \ 'xml' : 1,
    \ 'jinja' : 1,
    \}

The g:mta_use_matchparen_group option

When set to 1, forces the use of the MatchParen syntax group. This
is the same group that Vim uses to highlight parens, braces etc. This option is
useful for people who want to use the same highlight color for both constructs.

When set to 0, MTA will use a custom MatchTag syntax group with a default
highlight color. See the g:mta_set_default_matchtag_color option for
instructions on how to change that color.

By default, this option is set to 1 because this makes it very unlikely that
your colorscheme will conflict with the default colors used for the MatchTag

  1. It's the safe choice. Feel free to toggle this option to 0 (the author
  2. it like this).

Default: 1

let g:mta_use_matchparen_group = 1

The g:mta_set_default_matchtag_color option

This option only makes sense when g:mta_use_matchparen_group is set to 0. When
it is, g:mta_set_default_matchtag_color option can be used to prevent MTA from
overwriting any color you have set for the MatchTag group.

So, if you want to use a custom color for tag highlighting, have both
g:mta_use_matchparen_group and g:mta_set_default_matchtag_color set to 0 and
then set a custom color for MatchTag in your vimrc. For example, the
following command would set a light green text background and a black foreground
color ('foreground' is the text color):

highlight MatchTag ctermfg=black ctermbg=lightgreen guifg=black guibg=lightgreen

See :help highlight for more details on text highlighting commands.

Default: 1

let g:mta_set_default_matchtag_color = 1

Comands

You can use the plugin to also go to the closing tag if this tag is in the
visible screen.

MtaJumpToOtherTag

Jumps to the enclosing tag if the tag is visible. If you are on top of an
opening tag, it will jump to the closing tag. If you are on the closing tag,
it will jump to the opening tag. If you are inside a tag, then it will jump to
the closing tag.

Setting a mapping for this command:

nnoremap <leader>% :MtaJumpToOtherTag<cr>

FAQ

I've noticed that sometimes no tags are highlighted. Why?

The plugin only scans the lines that are visible in your window. If an opening
tag is visible but the closing tag is not, no tag will be highlighted. This is
for performance reasons (ie. what happens if the user opens a 10k HTML file?).

It's also possible that the plugin's parser is just out of ideas on how to
extract the enclosing tags out of your text. This should be very rare though.

Contact

If you have questions, bug reports, suggestions, etc. please use the [issue
tracker][tracker]. The latest
version is available at http://valloric.github.com/MatchTagAlways/.

The author's homepage is http://val.markovic.io.

License

This software is licensed under the GPL v3 license.
© 2012 Strahinja Val Markovic <<val@markovic.io>>.

添加新评论