Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add 'def' as one of the block matchers.

  • Loading branch information...
commit 114f952278eb8cdd7daead8830da6c88fa1f5221 1 parent ef0599c
@nelstrom authored
View
4 vim/bundle/textobj-rubyblock/plugin/textobj/rubyblock.vim
@@ -13,7 +13,7 @@ call textobj#user#plugin('rubyblock', {
" Misc. "{{{1
function! s:select_a()
- call searchpair('\v^[^#]*\zs(<if>|<do>|<module>|<class>)','','\v^[^#]*\zs<end>', 'cW')
+ call searchpair('\v^[^#]*\zs(<def>|<if>|<do>|<module>|<class>)','','\v^[^#]*\zs<end>', 'cW')
let end_pos = getpos('.')
normal %
@@ -23,7 +23,7 @@ function! s:select_a()
endfunction
function! s:select_i()
- call searchpair('\v^[^#]*\zs(<if>|<do>|<module>|<class>)','','\v^[^#]*\zs<end>', 'cW')
+ call searchpair('\v^[^#]*\zs(<def>|<if>|<do>|<module>|<class>)','','\v^[^#]*\zs<end>', 'cW')
let end_pos = getpos('.')
let end_pos[1] = end_pos[1] - 1
View
14 vim/bundle/textobj-rubyblock/test/examples.rb
@@ -16,7 +16,7 @@ class Foo
class Foo
# [cursor]
- # Should select Foo class
+ # vir/var should select Foo class
if true
# do not select inner block only
# search forwards.
@@ -26,7 +26,17 @@ class Foo
end
end
-[1,2,3,4,5].map |i| do
+module Foo
+ class Bar
+ def Baz
+ [1,2,3].each do |i|
+ i + 1
+ end
+ end
+ end
+end
+
+[1,2,3,4,5].map do |i|
# don't forget that a method can be called on 'end'!
i + 1
end.max
Please sign in to comment.
Something went wrong with that request. Please try again.