I'm looking for something like [[ (or [], ]], ][) that works with non-top-level function definitions instead of the next line with a top-level class or function definition on the first character.

class Foo():
  def __init__(self):

  def baz(self): #jump from here...

  def box(self): #... to here without searching or...

biz = 123

def bar(): #... without going straight here

It seems like, by default, vim ignores variable definitions and other things that start on the first character of a line, but when I'm looking through class methods, my only recourse is to search for def XYZ.


1 Answer 1


]m (and [m) seem to fit the bill. From :help ]m:

]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}

Simply pressing ]m will jump to the exact place you want to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.