8

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):
    pass

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

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

biz = 123

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

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.

0

1 Answer 1

12

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

                        *]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 that you have read and understand our privacy policy and code of conduct.

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