Is there a good way or plugin that can easily jump to the end of a python function in vim

When I look at the python code, I find it hard to know where the end of the function is if it has too many lines of code.

At first I think about finding the next one to def

be ok. But if the function is a decorator as shown below, this method does not work.

def require_player(view_func):
    @warps(view_func)
    def decorate(request, *args, **kwds):
        #my code here
        return
    return decorate

      

So, I want to know if there is a good way to do this in vim?

+3


source to share


2 answers


python-mode has bindings for this: eg. [[

and ]]

will jump back and forth between top-level functions. In your case, it will ignore the inner one def

, which I think is what you are asking for.



That's a lot of Kool-Aid to drink, but so far I haven't seen any major overhead when not using its features. So I leave it installed and see what else it can do when I feel like it’s like I’m doing with vim.

+3


source


There are Vim scripts / plugins that are designed to handle just such cases for you, such as Python.vim - they will give you bindings you can use to easily skip / select functions, classes, etc.



0


source







All Articles