Tuesday, February 28, 2012

Re: Vim Script that displays site-packages source python

On 02/28/2012 10:55 PM, Taylor Hedberg wrote:
> Taylor Hedberg, Tue 2012-02-28 @ 22:34:47-0500:

>>
>> It's quick and dirty, and would probably fail in some corner case, but
>> would something like this work?
>>
>> function! s:PySource(module)
>> let path = substitute(a:module, '\v(\w+)\.', '\1/', 'g')
>> execute 'view /usr/lib/python2.7/site-packages/' .
>> \ substitute(path, '/\w\+$', '', '') .
>> \ '.py'
>> execute '/\%(class\|def\)' substitute(path, '\v.*/(\w+)$', '\1', '')
>> endfunction
>> command! -nargs=1 PySource call s:PySource('<args>')
>>
>> It may require tweaking to work on your particular system (though it
>> works on my machine), but this should at least give you an idea of how
>> you might approach it.
>
> Or it might be easier to just use ctags to create an index of your
> site-packages directory, and then use Vim's tag lookup commands to
> navigate to the code you want to see.


That's what I do and it works really well. -ak

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment