Python PEP8 Autoformat
Python PEP8 Autoformat is a Sublime Text (2|3) plugin to interactively reformat Python source code according to PEP8 (Style Guide for Python Code).
Details
Installs
- Total 154K
- Win 74K
- Mac 41K
- Linux 39K
Nov 21 | Nov 20 | Nov 19 | 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 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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
- bitbucket.org
Python PEP8 Autoformat
Python PEP8 Autoformat is a Sublime Text plugin to interactively reformat Python source code according to PEP-8 (Style Guide for Python Code). Both Sublime Text versions 2 and 3 are supported.
History
Some time ago, looking for a possible Eclipse replacement, I gave a try to Sublime Text 2. One of my main usages of PyDev (very good Eclipse plugin for Python developer) is the code formatter.
Under Sublime Text 2 I installed PythonTidy but unfortunately it did not work for me. So, for fun and learning, I decided to create Python PEP8 Autoformat, based on autopep8 as code formatter and pep8 as code linter.
Installation
To avoid dependencies, all necessary modules are included within the package.
Using Sublime Package Control
- Use
cmd+shift+P
shortcut thenPackage Control: Install Package
- Look for
Python PEP8 Autoformat
and install it.
- Use
Using mercurial (hg) repository on bitbucket:
- Open a terminal, move to Packages directory (refers to the folder that opens when you use the Preferences > Browse Packages… menu). Then type in terminal:
hg clone https://bitbucket.org/StephaneBunel/pythonpep8autoformat 'Python PEP8 Autoformat'
Manually:
- Download an archive of Python PEP8 Autoformat
- Open a terminal, move to Packages directory (refers to the folder that opens when you use the Preferences > Browse Packages… menu) and create a new directory named 'Python PEP8 Autoformat'
- Extract archive contents in new 'Python PEP8 Autoformat' directory.
Settings
You'll find settings in Preferences menu (Preferences -> Package Settings -> Python PEP8 Autoformat -> …).
{
// autoformat code on save ?
"autoformat_on_save": false,
// enable possibly unsafe changes (E226, E24, W6)
// aggressive level, 0 to disable:
"aggressive": 0,
// list codes for fixes; used by --ignore and --select
"list-fixes": false,
// do not fix these errors / warnings (e.g. ["E501", E4", "W"])
"ignore": [],
// select errors / warnings (e.g. ["E4", "W"])
"select": [],
// Maximum line length
"max-line-length": 79
}
By editing User settings, your personal liking will be kept safe over plugin upgrades.
Indent size
PEP8 suggests using 4 spaces for indentation, but because that sometimes varies on a project by project basis, autopep8 has a –indent-size parameter.
If you wish to change the indent size, you can add in a key to your package settings. By default it uses 4.
{
...
"indent-size": 2,
...
}
Usage
Formatting is applied on the whole document.
Using keyboard:
- GNU/Linux:
ctrl+shift+r
- OSX:
ctrl+shift+r
- Windows:
ctrl+shift+r
Using Command Palette:
As defined in Default.sublime-commands
file:
[
{ "caption": "User: Python PEP8 Autoformat", "command": "pep8_autoformat" }
]
You can format your Python code by opening Command Palette (ctrl+shift+P) and type “auto”… up to highlight full caption.
Companions
Useful companions to Python PEP8 Autoformat:
- SublimeLinter - Inline lint highlighting
- MarkdownPreview - Markdown preview in browser
License
Copyright 2012-2014 Stéphane Bunel
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.