From f35eee382d936cf8025f34a8efcf11853e3572ba Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 8 Mar 2018 08:55:22 +0800 Subject: [PATCH] translated --- ... access-view Python help when using vim.md | 88 ------------------- ... access-view Python help when using vim.md | 86 ++++++++++++++++++ 2 files changed, 86 insertions(+), 88 deletions(-) delete mode 100644 sources/tech/20180131 How to access-view Python help when using vim.md create mode 100644 translated/tech/20180131 How to access-view Python help when using vim.md diff --git a/sources/tech/20180131 How to access-view Python help when using vim.md b/sources/tech/20180131 How to access-view Python help when using vim.md deleted file mode 100644 index f37a56908b..0000000000 --- a/sources/tech/20180131 How to access-view Python help when using vim.md +++ /dev/null @@ -1,88 +0,0 @@ -translating---geekpi - -How to access/view Python help when using vim -====== - -I am a new Vim text editor user. I am writing Python code. Is there is a way to see Python documentation within vim and without visiting the Internet? Say my cursor is under the print Python keyword, and I press F1. I want to look at the help for the print keyword. How do I show python help() inside vim? How do I call pydoc3/pydoc to seek help without leaving vim? - -The pydoc or pydoc3 command show text documentation on the name of a Python keyword, topic, function, module, or package, or a dotted reference to a class or function within a module or module in a package. You can call pydoc from vim itself. Let us see how to access Python documentation using pydoc within vim text editor. - -### Access python help using pydoc - -The syntax is: -``` -pydoc keyword -pydoc3 keyword -pydoc len -pydoc print -``` -Edit your ~/.vimrc: -`$ vim ~/.vimrc` -Append the following configuration for pydoc3 (python v3.x docs). Create a mapping for H key that works in normal mode: -``` -nnoremap H :execute "!pydoc3 " . expand("") -``` - - -Save and close the file. Open vim text editor: -`$ vim file.py` -Write some code: -``` -#!/usr/bin/python3 -x=5 -y=10 -z=x+y -print(z) -print("Hello world") -``` - -Position cursor under the print Python keyword and press Shift followed by H. You will see output as follows: - -[![Access Python Help Within Vim][1]][1] -Gif.01: Press H to view help for the print Python keyword - -### How to view python help when using vim - -[jedi-vim][2] is a VIM binding to the autocompletion library Jed. It can do many things including display help for keyword when you press Shift followed by K i.e. press capital K. - -#### How to install jedi-vim on Linux or Unix-like system - -Use [pathogen][3], [vim-plug][4] or [Vundle][5] to install jedi-vim. I am using Vim-Plug. Add the following line in ~/vimrc: -`Plug 'davidhalter/jedi-vim'` -Save and close the file. Start vim and type: -`PlugInstall` -On Arch Linux, you can also install jedi-vim from official repositories as vim-jedi using pacman command: -`$ sudo pacman -S vim-jedi` -It is also available on Debian (?8) and Ubuntu (?14.04) as vim-python-jedi using [apt command][6]/[apt-get command][7]: -`$ sudo apt install vim-python-jedi` -On Fedora Linux, it is available as vim-jedi using dnf command: -`$ sudo dnf install vim-jedi` -Jedi is by default automatically initialized. So no further configuration needed on your part. To see Documentation/Pydoc press K. It shows a popup with assignments: -[![How to view python help when using vim][8]][8] - -### about the author - -The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on [Twitter][9], [Facebook][10], [Google+][11]. - --------------------------------------------------------------------------------- - -via: https://www.cyberciti.biz/faq/how-to-access-view-python-help-when-using-vim/ - -作者:[Vivek Gite][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.cyberciti.biz -[1]:https://www.cyberciti.biz/media/new/faq/2018/01/Access-Python-Help-Within-Vim.gif -[2]:https://github.com/davidhalter/jedi-vim -[3]:https://github.com/tpope/vim-pathogen -[4]:https://www.cyberciti.biz/programming/vim-plug-a-beautiful-and-minimalist-vim-plugin-manager-for-unix-and-linux-users/ -[5]:https://github.com/gmarik/vundle -[6]:https://www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/ (See Linux/Unix apt command examples for more info) -[7]:https://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html (See Linux/Unix apt-get command examples for more info) -[8]:https://www.cyberciti.biz/media/new/faq/2018/01/How-to-view-Python-Documentation-using-pydoc-within-vim-on-Linux-Unix.jpg -[9]:https://twitter.com/nixcraft -[10]:https://facebook.com/nixcraft -[11]:https://plus.google.com/+CybercitiBiz diff --git a/translated/tech/20180131 How to access-view Python help when using vim.md b/translated/tech/20180131 How to access-view Python help when using vim.md new file mode 100644 index 0000000000..7219fcc393 --- /dev/null +++ b/translated/tech/20180131 How to access-view Python help when using vim.md @@ -0,0 +1,86 @@ +如何在使用 vim 时访问/查看 Python 帮助 +====== + +我是一名新的 Vim 编辑器用户。我用它编写 Python 代码。有没有办法在 vim 中查看 Python 文档而无需访问互联网?假设我的光标在 Python 的 print 关键字下,然后按下 F1。我想查看关键字 print 的帮助。如何在 vim 中显示 python help() ?如何在不离开 vim 的情况下调用 pydoc3/pydoc 寻求帮助? + +pydoc 或 pydoc3 命令显示关于 Python 关键字、主题、函数、模块或包的名称的文本文档,或在模块内或包中的模块对类或函数的引用。你可以从 vim 中调用 pydoc。让我们看看如何在 vim 编辑器中使用 pydoc 访问 Python 文档。 + +### 使用 pydoc 访问 python 帮助 + +语法是: +``` +pydoc keyword +pydoc3 keyword +pydoc len +pydoc print +``` +编辑你的 ~/ .vimrc: +`$ vim ~/.vimrc` +为 pydoc3 添加以下配置(python v3.x 文档)。在正常模式下创建 H 键的映射: +``` +nnoremap H :execute "!pydoc3 " . expand("") +``` + + +保存并关闭文件。打开 vim 编辑器: +`$ vim file.py` +写一些代码: +``` +#!/usr/bin/python3 +x=5 +y=10 +z=x+y +print(z) +print("Hello world") +``` + +将光标置于 Python 关键字 print 的下方,然后按下 Shift,然后按 H。你将看到下面的输出: + +[![Access Python Help Within Vim][1]][1] +Gif.01:按 H 查看 Python 关键字 print 的帮助 + +### 如何在使用 vim 时查看 python 帮助 + +[jedi-vim][2] 是一个绑定到自动补全库 Jed 的 vim。它可以做很多事情,包括当你按下 Shift 后跟 K 即按大写 K 就显示关键字的帮助。 + +#### 如何在 Linux 或类 Unix 系统上安装 jedi-vim + +使用 [pathogen][3]、[vim-plug][4] 或 [Vundle][5] 安装 jedi-vim。我使用的是 vim-plug。在 ~/vimrc 中添加以下行: +`Plug 'davidhalter/jedi-vim'` +保存并关闭文件。启动 vim 并输入: +`PlugInstall` +在 Arch Linux 上,你还可以使用 pacman 命令从官方仓库中的 vim-jedi 安装 jedi-vim: +`$ sudo pacman -S vim-jedi` +它也可以在 Debian(?8)和 Ubuntu(?14.04)上使用 [apt-get command][6]/[apt-get command][7] 安装 vim-python-jedi: +`$ sudo apt install vim-python-jedi` +在 Fedora Linux 上,它可以用 dnf 安装 vim-jedi: +`$ sudo dnf install vim-jedi` +Jedi 默认是自动初始化的。所以你不需要进一步的配置。要查看 Documentation/Pydoc,请按K。它将弹出帮助窗口: +[![How to view python help when using vim][8]][8] + +### 关于作者 + +作者是 nixCraft 的创建者,也是经验丰富的系统管理员和 Linux 操作系统/Unix shell 脚本的培训师。他曾与全球客户以及 IT、教育、国防和太空研究以及非营利部门等多个行业合作。在 [Twitter][9]、[Facebook][10]、[Google +][11] 上关注他。 + +-------------------------------------------------------------------------------- + +via: https://www.cyberciti.biz/faq/how-to-access-view-python-help-when-using-vim/ + +作者:[Vivek Gite][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.cyberciti.biz +[1]:https://www.cyberciti.biz/media/new/faq/2018/01/Access-Python-Help-Within-Vim.gif +[2]:https://github.com/davidhalter/jedi-vim +[3]:https://github.com/tpope/vim-pathogen +[4]:https://www.cyberciti.biz/programming/vim-plug-a-beautiful-and-minimalist-vim-plugin-manager-for-unix-and-linux-users/ +[5]:https://github.com/gmarik/vundle +[6]:https://www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/ (See Linux/Unix apt command examples for more info) +[7]:https://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html (See Linux/Unix apt-get command examples for more info) +[8]:https://www.cyberciti.biz/media/new/faq/2018/01/How-to-view-Python-Documentation-using-pydoc-within-vim-on-Linux-Unix.jpg +[9]:https://twitter.com/nixcraft +[10]:https://facebook.com/nixcraft +[11]:https://plus.google.com/+CybercitiBiz