Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim - run ctags on current python site-packages

Tags:

python

vim

ctags

This is what I need - have a key that will create ctags of my python site-packages.

I have this command, that will print the site-packages path:

!python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

This is how I to the key mapping:

map <F11> :!ctags -R -f ./tags *site-packages-path-goes-here*<CR>

How do I plug in the result of one command into the key binding statement?

The reason I want to get the site-packages path at the runtime is that I use virtualenv intensively. As the result the desired path changes all the time.

like image 800
ak. Avatar asked Jul 04 '10 19:07

ak.


2 Answers

This should work:

map <F11> :exe '!ctags -R -f ./tags ' . shellescape(system('python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"'))<CR>

But if your shell supports it, why not just:

map <F11> :!ctags -R -f ./tags `python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()`<CR>
like image 155
too much php Avatar answered Oct 22 '22 11:10

too much php


I know the answer given above works, but I'd like to suggest an alternative

map <F11> :!ctags -R -f ./tags $VIRTUAL_ENV/lib/python2.7/site-packages<CR>
like image 41
Chuan Yeong Avatar answered Oct 22 '22 09:10

Chuan Yeong