Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any command to go to the end (or beginning) of a Ruby block using vim

Tags:

vim

ruby

Is there a way to go the end of a Ruby block using vim? For example

module SomeModule

   # <Supposing that the cursor is HERE>
  def some_method
  end

end

I want to go from where the cursor is, to the end of the block with one command, is that possible?

I've read this documentation, but it doesn't seem to work on .rb files, I've read in some places that it only works on C (haven't tried though).

Thanks in advance.

like image 767
Roman Gonzalez Avatar asked Aug 14 '09 02:08

Roman Gonzalez


2 Answers

Looks like there is an official package at rubyforge that has some support for this:

The Ruby ftplugin now includes Ruby specific implementations for the [[, ]], [], ][, [m, ]m, [M, and ]M normal mode commands. These allow you to move to move quickly between module, class and method declarations.

Edit: The README says that these files are included in the default VIM distro but they don't work for me in GVIM on Windows, '{' and '}' seem to work on vim under Linux

like image 56
beggs Avatar answered Oct 14 '22 04:10

beggs


%

It works with most languages where it's clear that your cursor is on or near a block marker.

like image 26
greyfade Avatar answered Oct 14 '22 04:10

greyfade