Corey
by Corey
~1 min read

Categories

  • articles

Tags

  • Mac
  • Sublime

Python 遵循一套PEP8代码规范,今天发现了一个 Sublime 下格式纠正的插件,甚是好用,记录如下。

安装插件

  • cmd+shift+P»Package Control: Install Package
  • 找到Python PEP8 Autoformat这个包并安装

配置 User settings

找到User settings编辑如下内容,保存并退出。 Preferences»Package Settings»Python PEP8 Autoformat»Settings - User

{
    // 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
}

启用

找到写好的代码,用ctrl+shift+r纠正一下吧。