vim-tag-comment


Ⅰ. 插件描述

A Vim plugin that performs proper commenting of HTML/XML tags.

Ⅱ. 基本信息

创建日期:  2015-06-05
使用用户:  5
Github星:  8
插件作者:  Mark Volkmann

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'mvolkmann/vim-tag-comment'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

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

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'mvolkmann/vim-tag-comment'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'mvolkmann/vim-tag-comment'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/mvolkmann/vim-tag-comment

Ⅳ. 文档说明

This is a Vim plugin provides commands that
"properly" comment and uncomment HTML and XML tags.
All the plugins I have seen for this would take the following:

<foo> 
  <bar>baz</bar> 
</foo>

and comment it like this:

<!--<foo>-->
  <!--<bar>baz</bar>-->
<!--</foo>-->

This is ugly and excessive!
I believe the proper way to do this is:

<!--foo>
  <bar>baz</bar>
</foo-->

The provided ElementComment command does this and
the provided ElementUncomment command does the opposite.
These even support nested comments.
When a tag containing comments is commented out,
the comment delimiters are changed from <!-- --> to <!__ __>
so they can be restored if the tag is uncommented later.

This relies on the "vat" command to select the tag under the cursor.
It does not understand HTML tags that are not terminated (ex.
and <input>)
or XML tags that are terminated in the shorthand way (ex. <x/> and <x />).
There are separate commands (TagComment and TagUncomment)
to handle commenting and uncommenting those.

Unless already mapped to something else,
the following key mappings are configured:

  • <leader>tc :ElementComment<cr>
  • <leader>tu :ElementUncomment<cr>
  • <leader>tC :TagComment<cr>
  • <leader>tU :TagUncomment<cr>

The easiest way to install this is to use Pathogen and
"git clone" this repository into the .vim/bundle directory.

添加新评论