Create a Python editor under vim

Source: Internet
Author: User
Tags run python script virtual environment

In the previous article on the VIM Foundation plug-in plus a special for reading and writing Python program plug-in-python-mode. As the name implies, let vim run in Python mode. This section describes the features of this plugin and how to use it.

This article mainly extracts Python-mode's help document that individuals feel to use more and more meaningful content.

Introduction

Python-mode:includes libraries such as pylint, rope, Pydoc, Pyflakes, Pep8, and McCabe. Python-mode provides powerful functionality by integrating a variety of plugins.

Install

Use Neobundle to add the following code to the VIMRC, or download the extract directly. Vim/plugin directory

Bundle ' Klen/python-mode '

Function

Python-mode has a lot of features and configurations, but most of them only need to use the default configuration. Summarizing the Help Pymode, you can learn about its features by introducing his configuration items:

1. Turn on the Plugin:

Let G:pymode = 1 "Close and open the Python-mode plugin

2. Choose python version:

Let G:pymode_python = ' python ' "or Python3, disable." Choose the version of Python

3. Pep8-compatible python indent:

Let g:pymode_indent = 1 "Use indent style for PEP8

4. Enable Pymode Folding:

Let g:pymode_folding = 1 "Enable folding function

5. Show Document:

Let G:pymode_doc = 1 "via command: Pymodedoc ARG lookup document

Let G:pymode_doc_bind = ' K ' cursor moves to the parameter by pressing the shortcut key K

6. Run Code:

Let G:pymode_run = 1

Let G:pymode_run_bind = ' <leader>r ' "running in vim

7. Add Breakpoint

Let G:pymode_breakpoint_bind = ' <leader>b ' "Automatically joins the breakpoint statement

8. Code Checking:

Let G:pymode_lint_on_write = 1 "post-modification check

Let g:pymode_lint_checkers = [' Pyflakes ', ' pep8 ', ' McCabe '] "Choose from Pylint, Pep8, McCabe, pep257, Pyflakes

9. Rope Support (Build database of project files to index objects):

Let g:pymode_rope_ropefolder= '. Ropeproject ' "project file in the directory

Let G:pymode_rope_show_doc_bind = ' <c-c>d ' "Lookup help documentation

Ten. Completion

Grammar Completion Command:<c-p>/<c-n>

Others.

Let g:pymode_trim_whitespaces = 1 "trim unused white spaces on save

Let g:pymode_options = 1 "Setup Default python options

Let G:pymode_options_max_line_length = + "Setup Max line length

There are also features for code re-casting and the configuration of the virtual environment, because it is not used, so it is not introduced. Although there are many configurations, there are a few things that need to be used in VIMRC:

423 "for python-mode424 let G:pymode_rope_goto_definition_bind =" <C-]> "425 let G:pymode_python = ' python '" or Pyth On3, disable426 "Let G:pymode_virtualenv_path = $VIRTUAL _env427 to G:pymode_lint_on_write = 1428" Let G:pymode_rope_goto _definition_cmd = ' new ' or vnew

Finally summarize the command using

1). K: Consult the object document

2). <leader>r: Run Python script

3). <leader>b: Automatically add breakpoints

4). <c-p>/<c-n>: auto-complete

5). <c-]>: Jump to function definition

Create a Python editor under vim

Related Article

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.