How to access/view Python help when using Vim

Source: Internet
Author: User

How to access/view Python help when using Vim

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 accessing the internet? Assume that my cursor is in the PythonprintKeyword, and then press F1. I want to view the keywordprint. How to display python in vimhelp()? How to callpydoc3/pydocFor help?

pydocOrpydoc3Commands can display text documents based on Python keywords, themes, functions, modules, or package names, or reference classes or functions in modules or modules in the package. You can callpydoc. Let's take a look at how to usepydocAccess the Python documentation.

 

Use pydoc to access python help

Syntax:

Pydoc keyword
Pydoc3 keyword
Pydoc len
Pydoc print

Edit your~/.vimrc:

$ Vim ~ /. Vimrc

Ispydoc3Add the following configuration (python v3.x document ). Create in Normal ModeHKey ing:

Nnoremap <buffer> H: <C-u> execute "! Pydoc3 ". expand (" <cword> ") <CR>

Save and close the file. Open the Vim Editor:

$ Vimfile. py

Write some code:

#! /Usr/bin/python3
X = 5
Y = 10
Z = x + y
Print (z)
Print ("Hello world ")

Place the cursor in the Python keywordprintAnd then pressShift, And then pressH. You will see the following output:

Run H to view the help of the Python keyword print.

 

How to view python help when using Vim

Jedi-vim is a Vim plug-in bound to automatically complete the Jed library. It can do many things, including when you pressShiftFollowedK(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. In~/.vimrcAdd to downstream:

Plug 'David halter/jedi-vim'

Save and close the file. Start Vim and enter:

PlugInstall

On Arch Linux, you can also usepacmanCommand to install jedi-vim from vim-jedi in the official repository:

$ Sudo pacman-S vim-jedi

It can also use apt-get command/apt-get command On Debian (such as 8) and Ubuntu (such as 14.04) to install vim-python-jedi:

$ Sudo apt install vim-python-jedi

In Fedora Linux, it can be useddnfInstall vim-jedi:

$ Sudo dnf install vim-jedi

Jedi is automatically initialized by default. Therefore, you do not need further configuration. To view Documentation/Pydoc, pressK. It will pop up a Help window:

How to view python help when using vim

About the author

The author is the creator of nixCraft and a trainer of experienced system administrators and Linux operating systems/Unix shell scripts. He has worked with customers around the world, as well as IT, education, defense, space research, and non-profit sectors. Follow him on Twitter, Facebook, and Google +.

Via: https://www.cyberciti.biz/faq/how-to-access-view-python-help-when-using-vim/

Author: Vivek Gite Translator: geekpi Proofreader: wxy

This article was originally compiled by LCTT and launched with the honor of Linux in China

This article permanently updates link: https://www.bkjia.com/Linux/2018-03/151378.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.