I tried python-mode, it seems that it can work when I press K on "numpy.array", but if I want to press K on "np.array", it won't work.

  • 2
    That's because np is not the name of a module itself; it is a variable defined within the program to be another name for an already existing module. Therefore, you cannot find help on it without actually running the program. – zondo May 8 '16 at 1:28
  • @zondo I understand. If there's a way like vim help command, let me able to do :help(numpy.array). Or do you have some suggestions? – Eli May 8 '16 at 2:39
  • 2
    You could use :!pydoc numpy.array – zondo May 8 '16 at 2:41
  • @zondo, thanks! I don't need to google usage every time. – Eli May 8 '16 at 2:48
  • 1
    It's a pleasure! For more information, try :help :! from within Vim. You might also find man pydoc from the terminal to be interesting. – zondo May 8 '16 at 2:51

Try using the jedi-vim plugin. It uses Jedi to get completions and is much better at doing so than python-rope is. It will resolve np.array to numpy.array and show the appropriate documentation in a tab/split. Be warned that numpy is notoriously slow for Jedi to resolve when it's not cached.

zondo's suggestion to use :!pydoc numpy.array does work, but I find it annoying because I can't use Vim mappings to navigate the output, yank text from it, or leave it open for reference. There's also the issue of using a virutalenv, which may not have pydoc in the virtualenv's $PATH. In that case, you would have to use: :!python -m pydoc numpy.array.

  • That's pretty cool. – Eli May 8 '16 at 5:02

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.