vim-pairs


Ⅰ. 插件描述

Punctuation text objects: ci/ da; vi@ yiq da ...

Ⅱ. 基本信息

创建日期:  2011-04-05
使用用户:  24
Github星:  34
插件作者:  Dimitar Dimitrov

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

New punctuation text objects

ci/, di;, yi*, vi@ ...
ca/, da;, ya*, va@ ...

---

ciq (or "") changes content inside ANY kind of quotes
vaq, yiq ...

---

ci<space>, da<space> ... modify ANY punctuation pair

Supported punctuation signs

` " '
! $ % ^ & * _ - + = : ; @ ~ # | \ , . ? /

Algorithm:

Do in order. If a step succeeds skip the rest.

  1. _same line_: match under the cursor: act to the right if possible, else to the left
  2. _same line_: jump to a match on the left, then act to the right if possible or else repeat
  3. _same line and ↓_: try matching to the right, also past the current line
    if no match till EOF, start from byte one and do the same till initial position of cursor

Examples:

[] and | will represent the cursor

ciq or ""

Lorem [] dolor "          " adipisicing elit
Lorem    dolor "|" adipisicing elit

da^ or da<space>

Lorem    dolor "    ^ []  ^     " adipisicing elit
Lorem    dolor "         " adipisicing elit

vi@ or vi<space>

Lorem    dolor @        @        [@]  adipisicing elit
Lorem    dolor @        @---------@   adipisicing elit

Note: the above is different from what Vim would do.
_explanation_: '      '      ['] then ci' WON'T change anything!


di; or di<space>

Lorem  %     %  []  ;            ; elit
Lorem  %     %      ;; elit

gUiq

Lorem    dolor  '    val `  X  ' orem       ` adipisicing elit
Lorem    dolor  '    val `  X  ' OREM       ` adipisicing elit

yi. or yi<space>

Lorem    dolor  sit amet  []   adipisicing elit
incididunt ut labore .dolore. aliqua

Now: dolore is in reg "

""

START OF FILE
Lorem    dolor  ' sit amet     '  adipisicing elit
incididunt ut labore et dolore [] magna aliqua.
EOF

_Result after searching for a match and wrapping around EOF_:

START OF FILE
Lorem    dolor  '|'  adipisicing elit
incididunt ut labore et dolore [] magna aliqua.
EOF

添加新评论