+7

Code completion keyboard shortcut clashes with default system-wide shortcut on Mac OS X

Oleg Oshmyan 13 years ago updated 13 years ago 4
Ctrl+Space on Mac OS X opens the Spotlight search box by default. While this can be changed, it would be nice if the default keyboard shortcut for code completion in Sublime Text would not clash with it.
I believe Command+Space is the default OS X key binding for spotlight search
+2
Cmd+Space switches the keyboard layout, while Ctrl+Space opens Spotlight. (I just tried to reset my keyboard shortcuts to defaults, and this is still how they are assigned.) Perhaps Cmd+Space is the default for Spotlight if the user only has one keyboard layout set up, but I think this would be strange as it would mean the shortcuts would suddenly change when the user added another keyboard layout. On another note, all single-modifier shortcuts will the space bar are already taken (Cmd switches the keyboard layout, Option inputs a non-breakable space, Ctrl opens Spotlight, Shift… well, that does not quite give a shortcut, as people will expect it to just enter a space), as are Cmd+Option+Space, Option+Ctrl+Space and Ctrl+Shift+Space; it is hard to find a good shortcut for code completion at all.
By the way, in Xcode, the default shortcuts for code completion are Option+Escape to display a list of possible completions and Ctrl+. to instead complete the current word using the first possibility or cycle through them if pressed repeatedly.
Hmmm... I also would like to use the escape key for completion. So I came up with this key binding:

{ "keys": ["escape"], "command": "auto_complete", "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "[\"a-zA-Z0-9_]$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\"|'|.|,|\\)|]|$)", "match_all": true }
]
},