sponsor Vim development Vim logo Vim Book Ad

python tag import : guesses the import path of a python tag

 script karma  Rating 0/0, Downloaded by 1624  Comments, bugs, improvements  Vim wiki

created by
Michael Brown
script type
(Note this plugin is superceded by rope.vim).

repo: http://github.com/mjbrownie/Python-Tag-Import/tree/master. bugs/suggestions welcome

visual example here http://ttyshare.com/rec/michael/77604285/

This is for when you remember the name of a library function/class but not the module.path it is under

Eg. on a new line type. (control-b in insert mode is the default key but can be changed. see below)

to get complete import  options eg

from foo.bar.module import funcname
import foo.bar.module as module


In normal mode <leader>i will create an import for the current word

You can customise the import statements to your style preferences in your .vimrc eg

let g:pythontagimport_from = 0
turns off
from  foo.bar.module import funcname

let g:pythontagimport_from_mod = 0
turns off
from foo.bar import module #module.funcname

let g:pythontagimport_as = 0
turns off
import foo.bar.module as module #module.funcname

let g:pythontagimport_full  = 0
turns off
import foo.bar.module #foo.bar.module.funcname

" Usage:
"           You need a ctags file with the --fields=+i
"           option set
"           on a new line type the function you want to import
"           then hit the complete key
"           eg. type on a line
"           some_func
"           hit <c-b>in insert mode and get
"           from some.app.module.path import some_func
"           hotkey:
"               insert mode map.
"               <c-b> is the current default.
"           variables:
"               g:pythontagimportkey
"                   the key used to complete function
"                   parameters and key words.
"           This plugin is only as smart as your tags file.
"           Completion is created through inspecting the filename
"           in the tags file so functions that are rereferenced will not be
"           picked up. I put this out there in the hope someone can do
"           some fancy introspective alternative.
"           Setting the path can keep options relevant. At tht moment
"           it defaults to sys.path. It can come up with some bad guesses
"           Eg.
"           let g:python_path = ['/usr/lib/python2.4/site-packages/']

install details

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
python_tag_import.vim 0.3.1 2010-02-26 7.0 Michael Brown Uses getline for better expansion. Added a normal mode mapping to get the import statement forthe <cword>
python_tag_import.vim 0.3 2009-11-12 7.0 Michael Brown Added support for variations in python import statements. Eg. from ? import ?, import ? as ?, etc
python_tag_import.vim 0.1.1 2009-09-10 7.0 Michael Brown Fixed a bug introduced affecting relative directories
python_tag_import.vim 0.1 2009-09-09 7.2 Michael Brown Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.