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
Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 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.