Ⅰ. 插件描述
some textobjects for rubyⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'tek/vim-textobj-ruby-forever-and-always'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'tek/vim-textobj-ruby-forever-and-always'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'tek/vim-textobj-ruby-forever-and-always'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/tek/vim-textobj-ruby
Ⅳ. 文档说明
## Description
This defines four ruby text objects – block, class, function and name.
A block is delimited by the regex in the variable g:ruby_block_openers andend.
A function is a special case of block, starting with def, class works the
same way.
The inner variant doesn't include the delimiter lines.
A name is a module-scoped identifier like Module::Klass.
Usage
By default, the omaps ir and ar are used for a block; if and af for a
function, ic, ac for a class and an for a name.
Specifying a count selects outer blocks recursively.
Customization
The variable g:textobj_ruby_inclusive controls whether leading comments and a
single blank line are included in the a object if present, defaulting to 1.
Consult the documentation of textobj-user for custom mappings.
If g:textobj_ruby_inner_branch is 1, the inner block object will select the
lines between else, elsif, rescue and ensure (configurable viag:ruby_block_middles) and the boundaries instead of including all conditional
branches.
If g:textobj_ruby_no_mappings is 1, no actual mappings are created.
Details
The plugin uses a consistent line based approach, with the lines containing the
delimiters being part of the block.
This means that invoking the text object on the word before a do will select
the block opened by it, which is especially useful on empty blocks.
When the ir object is used on the opener line, the selection will begin on
the next line.
The reason for inclusive mode is that when deleting or copying a function, you
most likely want to paste it somewhere else and not leave an additional empty
line around (given that you separate all functions by a single blank line).
Comments directly above a block are most likely connected to it, so leaving
them would be impractical.
When invoked multiple times in visual mode, the selection grows to the next
larger block, just like when invoking the operator with a count.
To decide whether to grow, the visual selection is checked – if start and end
do not match, it is assumed that the selection is already a block.
This can result in faulty behaviour when invoked from visual mode with o
nonzero selection and the cursor on the end delimiter line – the next outer
block will be selected.
Dependencies
License
Copyright (c) Torsten Schmits. Distributed under the terms of the [MIT
License][2].