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.