Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim python navigate to imported files

Tags:

python

vim

ctags

who is this question may seem silly, but I'm stuck. I write gnuradio application in some python file. In VIM I try to open a file that is imported, for example:

from gnuradio import audio

Let's say I use the function:

audio.sink()

It is possible in vim to quickly get content of

sink()

function? In the manner of command CTRL-] of ctags.

P.s. using Ctags navigation to audio.sink() return me error: tag not found: sink. Using Ctags i can navigate only to local definitions ( not imported ). I check

ctags --list-kinds=python

import option is enabled. Inside tags file i see:

audio   fm_receiver.py  /^from gnuradio import audio$/;"    i
like image 439
user3583807 Avatar asked Aug 16 '14 22:08

user3583807


1 Answers

This works fairly quickly, but not exactly like you'd like. You add this line to your .vimrc

nnoremap <C-k> :!ctags -aR /usr/lib/python*/site-packages/<cword><cr>

Then you can hover over the package name gnuradio and press CTRL+K to execute the command which will append that packages source files to your local tags file (vim's default as well). Then you can CTRL+] over the sink keyword to get the function.

like image 75
Conner Avatar answered Sep 30 '22 09:09

Conner