1

I love that when working in python I can hover my cursor over a keyword a (e.g. math) and see docs in a less format to briefly read the api and then go back to writing.

I noticed in python, vim is loading python2.7 docs. Is there a way to change the default to 3?'

running OSX Catalina vim version 8.1.1312 and use homebrew for python3.X

1

Vim uses the pydoc command to display Python help, so if your system has a pydoc that defaults to Python 3, its setup will work as expected out of the box.

But I imagine that's perhaps not the case with Mac OS X and Python 3 from Homebrew. So you can consider updating your Vim setup to use a more appropriate pydoc that matches your system.

This setting is controlled by the 'keywordprg' option.

The Python filetype support shipped with Vim doesn't allow much customization for this particular option, so the best way for you to override it is to write your own custom Python filetype plug-in, that will run after the one in Vim runtimes, that will override 'keywordprg' to the setting that makes sense to your system.

Create a file named ~/.vim/after/ftplugin/python.vim and add this single line to it:

setlocal keywordprg=pydoc3

That's assuming you can use a pydoc3 command that's in your $PATH to look up Python 3 docs. If that's not the right command, update to one that will work for you. You can use a full path if needed. If you need spaces, escape them with backslashes. Example:

setlocal keywordprg=/usr/local/bin/python3\ -m\ pydoc

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.