Improved javascript snippet

This commit is contained in:
ujihisa 2013-05-30 19:33:05 -07:00
parent 67e38c80a9
commit 1f6f777f57

View File

@ -5,12 +5,19 @@ options head
} }
snippet function snippet function
alias func abbr func
options word options word
function ${1:#:function_name}(${2:#:argument}) { function ${1:#:function_name}(${2:#:argument}) {
${0:TARGET} ${0:TARGET}
} }
snippet function2
abbr func2
options head
function ${1:function_name}(${2:argument}) {
${0:TARGET}
}
snippet proto snippet proto
options head options head
${1:#:class_name}.prototype.${2:#:method_name} = function(${3:#:first_argument}) { ${1:#:class_name}.prototype.${2:#:method_name} = function(${3:#:first_argument}) {
@ -28,7 +35,8 @@ options head
${0:TARGET} ${0:TARGET}
} }
snippet ife snippet if-else
abbr ife
options head options head
if (${1:#:condition}) { if (${1:#:condition}) {
${0:TARGET} ${0:TARGET}
@ -37,25 +45,25 @@ options head
snippet for snippet for
options head options head
for (var ${2:i}=0; $2 < ${1:#:Things}.length; $2++) { for (var ${1:i}=0; $1 < ${2:#:Things}.length; ++$1) {
${0:TARGET} ${0:TARGET}
} }
snippet forin snippet forin
options head options head
for (var ${2:i} in ${1:#:Things}) { for (var ${1:i} in ${2:#:Things}) {
${0:TARGET} ${0:TARGET}
}; };
snippet ;, snippet key-value
abbr :,
options word options word
${1:#:value_name}:${0:#:value}, ${1:#:value_name}: ${0:#:value},
snippet key #snippet key
options word #options word
${1:#:key}: "${2:#:value}"}${3:, } # ${1:#:key}: "${2:#:value}"}${3:, }
snippet timeout snippet setTimeout-function
options head options head
setTimeout(function() {${0}}${2:}, ${1:10}); setTimeout(function() {${0}}, ${1:10});