ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Auto​PEP8

by wistful ST2/ST3

Automatically formats Python code to conform to the PEP 8 style guide using autopep8 and pep8 modules

Details

  • 3 2.2.0
    1.3.6
  • github.​com
  • github.​com
  • 2 weeks ago
  • 26 minutes ago
  • 6 years ago

Installs

  • Total 91K
  • Win 43K
  • OS X 23K
  • Linux 24K
Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4
Windows 36 21 81 45 42 47 42 27 33 46 43 41 37 43 19 30 39 50 41 31 44 42 36 40 45 56 40 44 30 29 35 47 55 48 52 30 38 45 40 66 41 52 21 24 26 34
OS X 7 9 12 16 16 25 19 12 8 8 16 13 10 18 7 12 23 18 16 35 13 5 11 16 23 20 17 19 10 14 12 25 25 22 12 10 7 20 27 21 13 24 7 17 16 23
Linux 6 10 22 15 13 23 16 8 11 11 18 15 25 15 11 13 12 15 28 29 24 13 16 18 26 24 15 19 7 10 18 18 25 23 20 14 14 22 23 23 23 25 14 7 23 22

Readme

Source
raw.​githubusercontent.​com

Sublime Auto PEP8 Formatting

About

Automatically formats Python code to conform to the PEP 8 style guide using autopep8 library.

Supports ST3 only.

Features

  • format / preview code according PEP8
  • format / preview selected text
  • format / preview all python modules in folder
  • side bar menu
  • format code while saving

Installing

The easiest way to install AutoPEP8 in through Package Control, which can be found at this site: http://wbond.net/sublime_packages/package_control.

Once you install Package Control, restart ST3 and bring up the Command Palette (Command+Shift+P on OS X, Control+Shift+P on Linux/Windows). Select “Package Control: Install Package”, wait while Package Control fetches the latest package list, then select AutoPEP8 when the list appears.

Pep8(pycodestyle) configuration

The extenstion supports both --global-config and --ignore-local-config options from the autopep8.

Settings

{

    "max-line-length": 79,

    // Do not fix these errors / warnings(e.g. E4, W)
    "ignore": "",

    // Select errors / warnings(e.g. E4, W)
    "select": "",

    // Number of spaces per indent level
    "indent-size": 4,

    // Don't look for and apply local config files;
    // if false, defaults are updated with any config files in the project's root directory.
    "ignore-local-config": false,

    // Path to a global pep8 config file;
    // if this file doesnot exist then this is ignored.
    "global-config": "",

    // Hang closing bracket instead of matching indentation of opening bracket's line.
    "hang-closing": false,

    // Specifies whether or not format files once they saved.
    "format_on_save": false,

    // If true - open new output panel with format/preview results.
    "show_output_panel": true,

    // Format/Preview menu items only appear for views
    // with syntax from `syntax_list`
    // value is base filename of the .tmLanguage syntax files
    "syntax_list": ["Python"],

    // The value shows how deep the plugin should look for *.py files
    // before disabling "Preview" and "Format" items in the Side Bar "AutoPep8" Context Menu.
    "file_menu_search_depth": 3, // max depth to search python files

    // If value is false(default)
    // then formatter doesn't treat absence of bottom empty line as an error
    // and doesn't try to fix it.
    "avoid_new_line_in_select_mode": false,

    // For debug purporse only.
    "debug": false,
    "logfile": "/tmp/sublimeautopep8.log"  // File to store debug messages.
}

Using

  • SideBar - right click on the file(s) or folder(s)
  • Active view - right click on the view
  • Selected text - right click on the selected text
  • On Save - provide by settings: option format_on_save
  • Command Palette - bring up the Command Palette and select PEP8: Format Code or PEP8: Preview Changes
  • Hotkeys - Command/Control + Shift + 8 to format code, Command/Control + 8 to preview changes