Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ctags vim - go to method definition in same python class

Tags:

python

vim

ctags

I have two classes in a python source file.

class A:
   def func(self):
       pass

class B:
   def func(self):
       pass

   def run(self):
       self.func()

When my cursor is in class B's 'self.func()' line, if press CTRL+], it goes to class A's func method. But instead I would like it to go B's func method.

like image 312
thavan Avatar asked Mar 24 '23 03:03

thavan


2 Answers

The <C-]> command jumps to the first tag match, but it also takes a [count] to jump to another one.

Alternatively, you can use the g<C-]> command, which (like the :tjump Ex command) will list all matches and query you for where you want to jump to (when there are multiple matches).

like image 163
Ingo Karkat Avatar answered Apr 01 '23 03:04

Ingo Karkat


Have a look at Jedi-Vim. It defines a new “go to definition” command, that will properly handle those situations.

like image 31
Chronial Avatar answered Apr 01 '23 02:04

Chronial