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

Python PEP8 Indent

by bperriot ST2

Plugin for Sublime Text 2 to properly indent Python code

Details

Installs

  • Total 498
  • Win 226
  • Mac 162
  • Linux 110
Dec 26 Dec 25 Dec 24 Dec 23 Dec 22 Dec 21 Dec 20 Dec 19 Dec 18 Dec 17 Dec 16 Dec 15 Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Python PEP 8 Indent

Sublime text 2 extension to add automatic python indentation, with compliance to PEP8.

Features

New lines are indented properly, depending on the previous line. Continuation lines are handled, as “end of block” keywords ('return', 'pass', …).

On new block keywords ('elif', 'else', 'except', …), the indent is aligned with the proper previous block.

The file 'example.py' were typed without pressing the tab or backspace key.

Caveat

PythonPEP8Indent works only with space indent, no tab indent.

Requirement

This plugin has no requirement beside sublime text 2. Sublime text 3 is currently not supported.

Install

Manual installation

Copy this directory into your sublime text package directory.

If you use the vintage mode, see “Settings”.

Settings

Use with vintage mode

Add the following lines to your keymap file, to remap the “new line” command:

{ "keys": ["o"], "command": "enter_insert_mode", "args":
    {"insert_command": "new_python_line", "insert_args":{"full_line":true}},
    "context": [{"key": "setting.command_mode", "match_all":true},
                 {"key":"selector", "operator":"equal",
                 "operand":"source.python", "match_all":true}]
},

{ "keys": ["O"], "command": "enter_insert_mode", "args":
    {"insert_command": "new_python_line", "insert_args":{"full_line":true, "forward":false}},
    "context": [{"key": "setting.command_mode"},
                {"key":"selector", "operator":"equal", "operand":"source.python"}]
}

Testing

Requirement

The test script requires the python libraries pytest and mock. They can be installed through pip or easy_install.

$ pip install -U pytest
$ pip install -U mock

$ easy_install -U pytest
$ easy_install -U mock

Execution

$ cd python_PEP8_indent
$ py.test

Bug reports & Contributions

Bug reports and contributions are welcome. PythonPEP8Indent is hosted on github.

License

Copyright © 2013 Bruno Perriot bperriot@gmail.com

This sublime text plugin is released under the terms of the MIT license.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.