wistful / SublimeAutoPEP8

Automatically formats Python code to conform to the PEP 8 style guide using autopep8 and pep8 modules
144 stars 23 forks source link

It's not possible to override default keymap #39

Closed wistful closed 8 years ago

wistful commented 8 years ago

Plugin is installed as Installed Packages/AutoPEP8.sublime-package and provides link only to the default plugin's keymap which can't be changed. The plugin should support keymap overriding.

wistful commented 8 years ago

Looks like it's not possible to override key bindings in the same way as for plugin settings. (http://sublime-text-unofficial-documentation.readthedocs.org/en/latest/reference/key_bindings.html) There is a workaround though. Default plugin's key bindings:

[
    { "keys": ["ctrl+8"], "command": "auto_pep8", "args": {"preview": true} },
    { "keys": ["ctrl+shift+8"], "command": "auto_pep8", "args": {"preview": false} }
]

To use different binding user should open Preferences -> Key Bindings - User and put the same lines but with different keys, e.g.

[
    // override default key binding with fake command
    { "keys": ["ctrl+8"], "command": "fake_command", "args": {} },
    { "keys": ["ctrl+shift+8"], "command": "fake_command", "args": {} },

    // set new key binding
    { "keys": ["ctrl+9"], "command": "auto_pep8", "args": {"preview": true} },
    { "keys": ["ctrl+shift+9"], "command": "auto_pep8", "args": {"preview": false} }
]