1

I am using davidhalter/jedi-vim plugin to navigate through Python definitions. If a definition is in the same file, the cursor is placed at the top or bottom of the screen. In these cases I usually press zz to center the view. I wonder is it possible to automatically execute zz after each jump?

Jedi-vim has this option:

let g:jedi#goto_command = "<leader>d"

But I guess its not the place where I should do the change to add zz after that command.

2

If you look at the plugin's code you'll find that the mapping is done like this:

execute 'nnoremap <buffer> '.g:jedi#goto_command.' :call jedi#goto()<CR>'

So what you can do is override that with your own ftplugin (:h ftplugin) and your own mapping. You could create ~/.vim/after/ftplugin/python.vim this is a file which will be executed when a buffer has the filetype python set. In this file you can reuse the original mapping but add zz at the end:

execute 'nnoremap <buffer> '.g:jedi#goto_command.' :call jedi#goto()<CR>zz'

And that should do what you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.