python-indent

Python PEP8 auto-indentation

Dustin Speckhals

463,278

170

1.2.6

MIT

GitHub

python-indent Build Status

Atom with easy PEP8 indentation...No more space bar mashing!

example of python-indent

Python Indent is the indentation behavior you've been waiting for in Atom! You should no longer have to worry about mashing your tab/space/backspace key every time you press enter in the middle of coding. Also, compared to other editors, there is no need to change an app configuration if you want to have a mixture of different types of indents (namely hanging and opening-delimiter-aligned).

The main obstacle with Atom's native indentation behavior is that it doesn't yet have the necessary API's to do what Python's PEP8 style guide suggests. Enhancement requests and issues have been opened in Atom Core on a few occasions, but none have been resolved yet.

This package was made to give you expected indentation behavior; python-indent listens for editor:newline events in Python source files, and when triggered, adjusts the indentation to be lined up relative to the opening delimiter of the statement or "hanging" (for parameters, tuples, or lists).

Indent Types

Both indent types for continuing lines as described in PEP 0008 -- Style Guide for Python Code are auto-detected and applied by this package.

Setting

Examples

def current_language_python_package(first_parameter, second_parameter,#<newline>
third_parameter):#<---default Atom language-python
    pass

def with_python_indent_package_added(first_parameter, second_parameter,
                                     third_parameter):
    #<--properly dedents to here
    pass

def with_hanging_indent(
    first_parameter, second_parameter, third_parameter):
    pass

also_works_with_lists = ["apples", "oranges", "pears", "peaches", "mangoes",
                         "clementines", "etc."]#<--PEP8 continued indentation
or_like_this = [
    "apples", "oranges", "pears",
    "peaches", "mangoes", "clementines",
    "etc."
]

There are plenty of other examples (ordinary and extraordinary) in the test_file.

This isn't working for me!

Sorry to hear that! Hopefully one of the following will help you fix the problem.