Ⅰ. 插件描述
Make text objects with various ruby block structures.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'rhysd/vim-textobj-ruby'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'rhysd/vim-textobj-ruby'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'rhysd/vim-textobj-ruby'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/rhysd/vim-textobj-ruby
Ⅳ. 文档说明
# Make text objects with various ruby block structures
This Vim plugin makes text objects with various ruby block structures.
Many end-terminated blocks are parsed using regex, indentation and syntax highlight.
This is more correct than parsing text with regex only.
This plugin requires vim-textobj-user
Simple one operator-pending mapping r
Operator-pending mapping r is added. dir, yar and other mappings are available like diw, yi'.if, unless, case, while, until, for, def, module, class, do, begin blocks are selected as text-objects.
Example:
#\% is the place of your cursor.
def hoge(yo)
if yo
puts "yo!"
#\%
end
puts "everyone!"
endTyping dar removes whole if block
def hoge(yo)
#\%
puts "everyone!"
endor dir removes innner if block.
def hoge(yo)
if yo
#\%
end
endWhen a cursor places at line 6,
def hoge(yo)
if yo
puts "yo!"
end
puts "everyone!" #\%
endtype dir removes inner def block.
def hoge(yo)
endOnly bellow mapping is defined.
| Description | Blocks | Operator-pending Mappings |
|---|---|---|
| any block with end-terminated | all blocks | r |
Or many operator-pending mappings for Ruby blocks
If you set g:textobj_ruby_more_mappings to 1, more mappings are defined.
You can specify kinds of Ruby blocks.
If you remember all mappings, it will be more convenient.
Combinations of textobjects and Ruby blocks are below.
| Description | Blocks | Operator-pending Mappings |
|---|---|---|
| definitions blocks | module, class, def | ro |
| loop blocks | while, for, until | rl |
| control blocks | do, begin, if, unless, case | rc |
| do statement | do | rd |
| any block including above all | all blocks | rr |