Ⅰ. 插件描述
To Toggle Comment of single/multiple lines of codeⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/toggle-comment'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/toggle-comment'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/toggle-comment'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/toggle_comment
Ⅳ. 文档说明
A small plugin to comment, un-comment or toggle one or more lines in both normal and visual mode.
Usage
In normal or visual mode:
q to toggle comment
shift-q to force comment
alt-q to force un-comment
Also avaible in command mode:
Ct to toggle comment
Cc to force comment
Cu to force un-comment
These 3 commands are compatible with range and global (:g)
Examples
'yyqp' : duplicate and comment an uncommented line
'vjq' : when two lines are [1 commented/1 un-commented], switch the state of each line
':g!/toto/Cc' : comment all lines which not contain 'toto'
Remarks
- The plugin will check the option "&filetype" and the variable "b:current_syntax" to know how to comment the file.
- "echo &filetype" or "echo b:current_syntax" will give you the name of the syntax of the opened file.
- Add a new syntax to the script (or change the default behavior) is very very simple (add only one line), so don't hesitate to adapt the script.
- For languages like fortran where the rest of the line should not be disturbed by the comment symbol, don't forget to add a line to "s:comment_in_place".