commentop.vim


Ⅰ. 插件描述

commands and operators to comment/uncomment lines in many languages

Ⅱ. 基本信息

创建日期:  2009-07-08
使用用户:  3
Github星:  1
插件作者:  Takahiro SUZUKI

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

!!NOTICE!! NO BACKWARD COMPATIBILITY FOR 1.0.2 OR BEFORE !!

Description:
  This plugin provides a set of commands and operators  to comment or
  uncomment lines. Linewise comment token (such as double quote in vim
  script) is detected automatically by looking up filetype of the file.
  Filetypes working well by default:
    vim, python, perl, ruby, haskell, sh, bash, zsh, java, javascript,
    Makefile, tex
  With definition in this script, these also work:
    (c), cpp, csharp, php, matlab

  You can also easily define your own comment token for filetype. Add below
  in your .vimrc:
    CommentopSetCommentType FILETYPE REMOVEPATTERN INSERTSTRING

  plugin keymaps:
    <Plug>CommentopToggleNV    " (n/v) toggle comment [count] or visual lines
    <Plug>CommentopAppendNV    " (n/v) comment out [count] or visual lines
    <Plug>CommentopRemoveNV    " (n/v) uncomment [count] or visual lines

    <Plug>CommentopToggleOP    " (n op) toggle comment {motion}
    <Plug>CommentopAppendOP    " (n op) comment out {motion}
    <Plug>CommentopRemoveOP    " (n op) uncomment {motion}

  default mapping:
    co       <Plug>CommentopToggleNV
    cO       <Plug>CommentopAppendNV
    c<C-O>   <Plug>CommentopRemoveNV

    go       <Plug>CommentopToggleOP
    gO       <Plug>CommentopAppendOP
    g<C-O>   <Plug>CommentopRemoveOP

Examples:
  in normal mode:
     co          " toggle comment for this line
     3cO         " comment out 3 lines

  in normal mode (operator):
     goip        " toggle comment for this paragraph
     gOa{        " comment out this {} block

  in visual mode:
     c<C-O>      " remove comments in visual selection

添加新评论