Skip python "import" statements in exuberant ctags


Question

if I have two files

file a.py:

class A():
    pass

file b.py:

from a import A
b = A()

When I use ctags and press Ctrl+] in vim, it redirects me to import statement, not to class definition. In this code all is ok:

file a.py:

class A():
    pass

file b.py:

from a import *
b = A()
1
26
8/31/2010 1:25:09 PM

Accepted Answer

You can add the following line to your ~/.ctags file.

--python-kinds=-i

to have ctags skip indexing import statements. To see what else you can enable/disable:

ctags --list-kinds=python

51
9/8/2010 4:52:04 PM

I use a mapping similar to the following which allows me to choose when there are multiple matches for a given tag:

nnoremap <C-]> :execute 'tj' expand('<cword>')<CR>zv

Also, check the man page for ctags, you might find there is a way to disable this type of tagging.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon