On GitHub I have a jQuery completions file which you/all are welcome to use, modify, etc. You might create a jQuery folder within your Packages area, and copy the file to there. [You can rename the file if you like ]
It uses the scope source.js.jquery so you will need a jQuery syntax file - *mrmartineau *has one available via Package Control or GitHub. He also has a collection of jQuery snippets, but my preference is to use a single completions file. Alternatively, if you mainly use jQuery anyway, you could just modify the scope to source.js; this way, the completions will be available in any .js file.
I use the following key-bindings to allow me to use one completion within another:
[code] { “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 }
]
},[/code]
For example, if I’ve started the ‘click()’ completion it looks like the following - with the phrase ‘[eventData, ]’ highlighted:
$('#thing').click([eventData, ]handler)
I might press Delete if I don’t need the event data; press Tab to highlight the word ‘handler’; press the right-arrow to get the end of this word, and then press Ctrl-Alt-Right arrow to obtain the following:
[code] $(’#thing’).click(function () {
})[/code]
I can then continue to tab through the (two or more) completions. This works for either the word ‘handler’ or ‘callback’ - they both invoke an anonymous function.