Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip python "import" statements in exuberant ctags

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() 
like image 242
Андрей Костенко Avatar asked Aug 31 '10 13:08

Андрей Костенко


People also ask

Does Ctags work with Python?

Ctags supports indexing of many modern programming languages. Python is a powerful scriptable dynamic language. Using Python to access Ctags index file is a natural fit in extending an application's capability to examine source code. This project wrote a wrapper for readtags.

What is exuberant ctags?

Exuberant Ctags (e-ctags) maintained by Darren Hiebert, the ancestor of Universal Ctags, improved traditional ctags with multi-language support, the ability for the user to define new languages searched by regular expressions (called optlib in Universal Ctags), and the ability to generate emacs-style TAGS files.

Does order of imports matter python?

Import order does not matter. If a module relies on other modules, it needs to import them itself. Python treats each . py file as a self-contained unit as far as what's visible in that file.


1 Answers

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

like image 84
okay zed Avatar answered Sep 19 '22 19:09

okay zed