Quickly open Python modules in vim
Quickly open Python modules based on Python import paths.
This is particularly useful for viewing/editing third-party packages in a virtual environment.
:Ped <path.to.module>
:Ped django.shortcuts
:Ped django.views.generic.TemplateView
" Partial matches work, too
:Ped django.views.generic.Templ
Requires the ped Python package (installable with pip
).
$ pip install -U ped
Then add this plugin using your favorite plugin manager.
Using vim-plug:
" ~/.vimrc
Plug 'sloria/vim-ped'
<Plug>PedPrompt
: Shortcut to input :Ped
in the command line.<Plug>PedVword
: Input :Ped pkg
in the command line, where "pkg" is the current visual selection.<Plug>PedVwordExec
: Like <Plug>PedVword
, but executes immediately.<Plug>PedCword
: Input :Ped pkg
in the command line, where "pkg" is the current word under the cursor.<Plug>PedCwordExec
: Like <Plug>PedCword
, but executes immediately.nmap <leader>e <Plug>PedPrompt
nmap <leader>E <Plug>PedCwordExec
vmap <leader>e <Plug>PedVwordExec
" Vim command to open files, defaults to 'edit'
" Examples: 'tabedit', 'split', 'vsplit'
let g:ped_edit_command = 'edit'
" ped executable, defaults to 'ped'
let g:ped_executable = 'ped'