brackets-snippets
brackets-snippets copied to clipboard
Suggestion: enhancement in the syntax (loops)
Hi. What about this?
/**
*
${2:loop(, )}
* @param ${2} ${2.1}
${2:/loop}
*/
function ${1:name} (${2:params}) {
${3}
}
This way:
- the first focus is in $1 ... user types "createClient" and hits tab
- focus on both $2
- user types "name", tab, "The client name."
- results in:
/**
* @param name The client name.
*/
function createClient (name) {
${3}
}
- user hits tab again, and cursor goes back to where it was before(outside the loop) adding the separator(", ", in this case) just before it.
/**
* @param name The client name.
*/
function createClient (name, [CURSOR]) {
${3}
}
- user types "age", tab, "The client's age."
- result now it:
/**
* @param name The client name.
* @param age The client's age.
*/
function createClient (name, age, [CURSOR]) {
${3}
}
- user hits tab, not typing anything
- removes the last separator, and focus on $3.
/**
* @param name The client name.
* @param age The client's age.
*/
function createClient (name, age) {
[CURSOR]
}
It's just a suggestion, but I think this feature would give much power to a new level of snippets.
Interesting but you can create a function snippet and use this extension: https://github.com/wikunia/brackets-funcdocr for param options.
FuncDocr is really interesting, but I was using the annotation comment just as an example.
The loop feature for snippets could be used for many other things.
Imagine using this for css...so you can create a snippet which would bring the : and ; for each line/property.
Or in HTML, a snippet that allowed you to create tables or LIs where with a simple TAB you could add a new set of tags.
I know emmet is good for things like that too, but this way, you would have a repeatable pattern (and could edit it, tab by tab).