smartpairs


Ⅰ. 插件描述

Enchanted visual (selection) mode for Vim

Ⅱ. 基本信息

创建日期:  2012-12-11
使用用户:  79
Github星:  162
插件作者:  Alexander Gorkunov

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

Build Status

Status

About

smartpairs allows you to forget about difficult keys combination like vi{ or va".

Now you can use only one shortcut for all typical combinations. Even if you've already
selected something you can easily correct selection by using smartpairs.

Below is a screenshot showing how plugin works:

smartpairs.vim

Plugin searches first unpair symbol from the left of the current cursor
position and then runs target command with this symbol. When you press
v again plugin extends current selection to the next pairs.

Installation

Use pathogen.vim for quick plugin installation.

If you already have pathogen then put smartpairs into ~/.vim/bundle like this:

cd ~/.vim/bundle
git clone https://github.com/gorkunov/smartpairs.vim.git

Super fast selection

By default smartpairs focuses on fast selection. You can position cursor to any place inside pairs objects
such as () and just type vv and that's all. If you need to extend selection you just type again v.
This is so simple and fast. Smarpairs also supports delete/yank operations see mappings below.
But again most of the time (99%) I use just one combination: vv.

Cancel last smartpairs selection

You can use Ctrl+Shift+v keys combination to cancel last selection operation.

Mappings

vi* -> viv
va* -> vav
ci* -> civ
ca* -> cav
di* -> div
da* -> dav
yi* -> yiv
ya* -> yav
Where * is in <, >, ", ', `, (, ), [, ], {, } or t as tag

After v* commands you can press v again and selection will be extended to
the next pairs.

Uber Mode (enabled by default)

Uber mode enables combination 'i' and 'a' modes. Let's see how it works:

We have a line (cursor position under _):

( 'te_st' )

Without uber mode our keys combination converts to:


viv -> vi'
v   -> vi(

With uber mode:


viv -> vi'
v   -> va'
v   -> vi(
v   -> va(

To enable uber mode set g:smartpairs_uber_mode = 1 in your vimrc.

Advanced configuration

For changing smartpairs keys binding add those lines to your .vimrc file:

"Key for running smartpairs in all modes (select/delete/change/yank)
"default is 'v'
let g:smartpairs_key = 'v'

"Key for running smartpairs in the selection mode 
"(extend current selection to the next pairs)
"default is 'v'
let g:smartpairs_nextpairs_key = 'v'

"Enable 'uber mode' (see above)
"default is 1
let g:smartpairs_uber_mode = 1

"Start selection from word
"If there is no regions then select word
"default is 0
let g:smartpairs_start_from_word = 1

"Key for running smartpairs in the selection mode
"for extending selection with IN-mod (like vi")
"default is 'm'
let g:smartpairs_nextpairs_key_i = 'm'

"Key for running smartpairs in the selection mode 
"for extending selection with ABOVE-mod (like va")
"default is 'M'
let g:smartpairs_nextpairs_key_a = 'M'

"Keys combination for canceling last smartpais selection
"default is '<C-V>' Ctrl+Shift+v
"under macvim you can use Cmd key e.g. <D-V> -> Cmd+Shift+v
let g:smartpairs_revert_key = '<C-V>'

"Smartpairs works only with 20 lines before cursor position
"but you can changes this limit:
let g:smartpairs_maxdepth = 20

License

Smartpairs is released under the wtfpl

添加新评论