Unfortunately there is not option to change the behavior of these motions similar to '
' or that kind of stuff.
This is the description from the vim documentation: (I also searched in the list of options for something related to this and there is nothing).
]m Go to [count] next start of a method (for Java or
similar structured language). When not before the
start of a method, jump to the start or end of the
class. When no '{' is found after the cursor, this is
an error. exclusive motion. {not in Vi}
The above two commands assume that the file contains a class with methods.
The class definition is surrounded in '{' and '}'. Each method in the class
is also surrounded with '{' and '}'. This applies to the Java language. The
file looks like this: >
// comment
class foo {
int method_one() {
body_one();
}
int method_two() {
body_two();
}
}
Starting with the cursor on "body_two()", using "[m" will jump to the '{' at
the start of "method_two()" (obviously this is much more useful when the
method is long!). Using "2[m" will jump to the start of "method_one()".
Using "3[m" will jump to the start of the class.
Here is an interesting thing. I noticed that [m and ]m works on python so I was curious (looking a the documentation ) how it works since Python doesn't have braces to enclose functions.
I checked the vim source code and here is what I found in share/vim/vim73/ftplugin/python.vim:
nnoremap <silent> <buffer> ]m :call <SID>Python_jump('/^\s*\(class\\|def\)')<cr>
nnoremap <silent> <buffer> [m :call <SID>Python_jump('?^\s*\(class\\|def\)')<cr>
They did it in a similar fashion.
I can see they did it as a motion and their commands can jump multiple defs and it also jumps to class.
I will work on refining the regexp as it misses some cases and also to make it a motion command (I wanted to do that for a while, I just never actually did it :) ). I will post it here after that.
If there is a desire to add it in the main distribution it's fine. If not people can add those in their .vimrc if they want to.
Regards.
Catalin.