Spacevim Language Module Python

Source: Internet
Author: User

Original link: https://spacevim.org/cn/layers/lang/python/

    • Module Introduction
    • Functional characteristics
    • dependent on installation and enabling modules
      • Enable module
      • Grammar check
      • Code formatting
      • Format Imports
    • Shortcut keys
      • Jump to Definition
      • Code generation
      • Interactive programming
      • Run the current script
      • Organize Imports
Module Introduction

This module provides support for Python development in Spacevim, including code completion, syntax checking, code formatting, interactive programming, and debugging features.

Functional characteristics
    • Code completion
    • Document Lookup
    • Grammar check
    • Code formatting
    • Interactive programming
    • Code debugging
Dependent installation and Enable module enable module

You can enable the module by adding the following configuration to the configuration file:

[[layers]]  name = "lang#python"
Grammar check

checkersThe module provides code-checking functionality, plus the need to install flake8 packages:

pip install --user flake8
Code formatting

The default code formatting shortcut keys are SPC b f , and need to be installed yapf . If you need to save the file automatically format the Python file, you need to set it format-on-save to true .

pip install --user yapf
Format Imports

If you need to remove unused imports more easily, you need to install Autoflake:

pip install --user autoflake

You can quickly sort the imports by installing Isort:

pip install --user isort
Shortcut keys jump to Definition
Mode Key Description
Normal g d Jumps to the definition of the cursor function
Code generation
Mode shortcut Keys Key Description
Normal SPC l g d Generate DocString
Interactive programming

Start python or ipython interactive process, shortcut keys are: SPC l s i . If an executable command exists ipython ,
The command is used as the default interactive command, otherwise the default command is used python . You can modify executable commands by setting up a virtual environment.

Transfer code to the REPL process execution:

shortcut Keys Description
SPC l s b Send entire file contents to REPL
SPC l s l Send current line contents to REPL
SPC l s s Send the selected content to REPL
Run the current script

When editing a Python file, you can SPC l r quickly and asynchronously run the current file by using the shortcut key, and the results will be displayed in a separate execution window.

Organize Imports
shortcut Keys Key Description
SPC l i r Use Autoflake to remove unused guide packs
SPC l i s Using Isort to sort the guide pack

Spacevim Language Module Python

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.