Using Sublime Text 3.2., Build 3200, Windows 10, Slovenian keyboard layout:
I managed to solve same problem via: Preferences --> Key Bindings and then replaced all contents with this code similar to previously mentioned:
[
{
"command": "insert",
"args": {"characters": "]"},
"keys": ["ctrl+alt+g"],
"context": [
{"key": "selector", "operator": "equal", "operand": "source.python"}
]
},
{
"command": "insert",
"args": {"characters": "[]"},
"keys": ["ctrl+alt+f"],
"context": [
{"key": "selector", "operator": "equal", "operand": "source.python"}
]
},
]
Difference here from above code is that this code is starting with “[” and ending with “]” (maybe this was assumed in previous post, I don’t know). Second change is in line 12 from this code:
"args": {"characters": "["},
to this code:
"args": {"characters": "[]"},
This tweak allows you that when typing lists in Python when you press “[” result output is “[]”. This is same behavior like when you type in “(” and result is “()” or when you type “{” and result is “{}” in your Python code. Just makes it easier to code when parenthesis are opened and closed immediately.
EDIT: Only thing I didn’t know how to do is to put cursor in the middle of “[]”. After some Googling here is the solution:
- Install ChainOfCommand (see details on: https://github.com/jisaacks/ChainOfCommand) via Package Control: Install Package (Shortcut: Ctrl+Shift+P)
- Put this code via Preferences --> Key Bindings instead of the above:
[
{
"command": "insert",
"args": {"characters": "]"},
"keys": ["ctrl+alt+g"],
"context": [
{"key": "selector", "operator": "equal", "operand": "source.python"}]},
{
"keys": ["ctrl+alt+f"],
"command": "chain",
"args": {
"commands": [
["insert", {"characters": "[]"}],
["move", {"by": "characters", "forward": false}] ,
]
}
}
]
Hope it helps - it bugged me for few hours till I solved it - so I know this can be annoying! 