Create or add the following to your User - Key Bindings.
- Code: Select all
[
{ "keys": ["ctrl+alt+right"], "command": "insert_best_completion", "args": {"default": "", "exact": true} },
{ "keys": ["ctrl+alt+right"], "command": "insert_best_completion", "args": {"default": "", "exact": false},
"context":
[
{ "key": "setting.tab_completion", "operator": "equal", "operand": true }
]
},
{ "keys": ["ctrl+alt+right"], "command": "replace_completion_with_next_completion", "context":
[
{ "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
{ "key": "setting.tab_completion", "operator": "equal", "operand": true }
]
},
{ "keys": ["ctrl+alt+left"], "command": "replace_completion_with_prev_completion", "context":
[
{ "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
{ "key": "setting.tab_completion", "operator": "equal", "operand": true }
]
},
// insert best completion for current word:
{ "keys": ["ctrl+shift+c"], "command": "run_macro_file",
"args": {"file": "Packages/User/bestcomp.sublime-macro"} }
]
Then create the following macro named bestcomp.sublime-macro.
- Code: Select all
[
{
"args":
{
"by": "characters",
"forward": false
},
"command": "move"
},
{
"args":
{
"by": "word_ends",
"forward": true
},
"command": "move"
},
{
"args":
{
"default": "",
"exact": false
},
"command": "insert_best_completion"
}
]
[You can just copy the above to a new, blank file and save it with the correct name and extension.]
When you are within a completion type the name (or the first few letters) of the completion you wish to use and press Ctrl-Shift-C to insert this completion. You should then be able to Tab through the remaining fields. [I should say that this works for me, but I can't guarantee it
If you have pressed Ctrl-Shift-C and the wrong completion is assumed, press Ctrl-Alt-Left or Ctrl-Alt-Right to cycle backwards and forwards through other completions.
This has particular relevance to my jQuery completions file (NB it requires a jQuery syntax file!). If I use my ready() completion:
- Code: Select all
$(document).ready(handler)
the word handler is highlighted and I can press Ctrl-Shift-C to obtain:
- Code: Select all
$(document).ready(function (|) {
|
}|)|
with the tab/field positions as indicated by the pipes. This is because the words handler (and callback) are also completions within my jQuery completions file.
As a matter of fact, it tends to work with just the Ctrl-Alt-Left/Right shortcuts, without the need for the macro (Ctrl-Shift-C) file. But it's nice to have alternatives