How to access / view Python help when using Vim
This article mainly introduces how to access / view Python help when using Vim, the article is very detailed, has a certain reference value, interested friends must read it!
I am a new Vim editor user. I use it to write Python code. Is there a way to view Python documents in vim without having to access the Internet? Suppose my cursor is under the print keyword in Python, and then press F1, I want to see the help of the keyword print. How do I display python help () in vim? How do I call pydoc3/pydoc for help without leaving vim?
The pydoc or pydoc3 command can display a text document based on the name of a Python keyword, topic, function, module, or package, or a reference to a class or function by a module within a module or package. You can call pydoc from Vim. Let's take a look at how to use pydoc to access Python documents in the Vim editor.
Use pydoc to access python help
The syntax is:
Pydoc keywordpydoc3 keywordpydoc lenpydoc print
Edit your ~ / .vimrc
$vim ~ / .vimrc
Add the following configuration for pydoc3 (python v3.x documentation). Create a mapping of the H key in normal mode:
Nnoremap H: execute "! pydoc3". Expand ("")
Save and close the file. Open the Vim editor:
$vim file.py
Write some code:
#! / usr/bin/python3x=5y=10z=x+yprint (z) print ("Hello world")
Place the cursor below the Python keyword print, then press Shift, and then press H. You will see the following output:
Press H to view help for the Python keyword print
How to view python help when using Vim
Jedi-vim is a Vim plug-in that binds the auto-completion library Jed. It can do a lot of things, including displaying keyword help when you press Shift followed by K (that is, press uppercase K).
How to install jedi-vim on Linux or Unix-like systems
Install jedi-vim using pathogen, vim-plug, or Vundle. I am using vim-plug. Add the following line to ~ / .vimrc:
Plug 'davidhalter/jedi-vim'
Save and close the file. Start Vim and enter:
PlugInstall
On Arch Linux, you can also use the pacman command to install jedi-vim from vim-jedi in the official repository:
$sudo pacman-S vim-jedi
It can also install vim-python-jedi using apt-get command/apt-get command on Debian (such as 8) and Ubuntu (such as 14.04):
$sudo apt install vim-python-jedi
On Fedora Linux, it can install vim-jedi with dnf:
$sudo dnf install vim-jedi
Jedi is initialized automatically by default. So you don't need further configuration. To view Documentation/Pydoc, press K. It will pop up the help window:
The above is all the contents of the article "how to access / View Python help when using Vim". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!