https://github.com/rhysd/vim-textobj-ruby
Make text objects with various ruby block structures.
https://github.com/rhysd/vim-textobj-ruby
Last synced: over 1 year ago
JSON representation
Make text objects with various ruby block structures.
- Host: GitHub
- URL: https://github.com/rhysd/vim-textobj-ruby
- Owner: rhysd
- Created: 2012-11-07T09:03:23.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2019-04-20T19:26:13.000Z (over 7 years ago)
- Last Synced: 2025-04-14T10:04:42.031Z (over 1 year ago)
- Language: Vim script
- Size: 21.5 KB
- Stars: 57
- Watchers: 2
- Forks: 12
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://github.com/kana/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.
```ruby
def hoge(yo)
if yo
puts "yo!"
#\%
end
puts "everyone!"
end
```
Typing `dar` removes whole `if` block
```ruby
def hoge(yo)
#\%
puts "everyone!"
end
```
or `dir` removes innner `if` block.
```ruby
def hoge(yo)
if yo
#\%
end
end
```
When a cursor places at line 6,
```ruby
def hoge(yo)
if yo
puts "yo!"
end
puts "everyone!" #\%
end
```
type `dir` removes inner `def` block.
```ruby
def hoge(yo)
end
```
Only 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