From a2e07d15e1fadf1f9f39c6ad95076f4fd3e6f19b Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Sun, 15 Aug 2010 14:35:14 +0200 Subject: [PATCH] Cleaned up JavaScript snippets --- ...avascript.snippets => javascript.snippets} | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) rename UltiSnips/{tm_javascript.snippets => javascript.snippets} (59%) diff --git a/UltiSnips/tm_javascript.snippets b/UltiSnips/javascript.snippets similarity index 59% rename from UltiSnips/tm_javascript.snippets rename to UltiSnips/javascript.snippets index 4f38f05..e62abd7 100644 --- a/UltiSnips/tm_javascript.snippets +++ b/UltiSnips/javascript.snippets @@ -1,8 +1,11 @@ +########################################################################### +# TextMate Snippets # +########################################################################### snippet get "Get Elements" getElement${1/(T)|.*/(?1:s)/}By${1:T}${1/(T)|(I)|.*/(?1:agName)(?2:d)/}('$2') endsnippet -snippet '':f "Object Method String" +snippet '':f "object method string" '${1:${2:#thing}:${3:click}}': function(element){ $0 }${10:,} @@ -18,26 +21,26 @@ snippet :, "Object Value JS" ${1:value_name}:${0:value}, endsnippet -snippet : "Object key — key: "value"" +snippet : "Object key key: 'value'" ${1:key}: ${2:"${3:value}"}${4:, } endsnippet snippet proto "Prototype (proto)" -${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) { +${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) ,,{ ${0:// body...} }; - + endsnippet -snippet for "for (…) {…} (faster)" -for (var ${20:i} = ${1:Things}.length - 1; ${20:i} >= 0; ${20:i}--){ - ${100:${1:Things}[${20:i}]}$0 +snippet for "for (...) {...} (faster)" +for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2--){ + ${3:$1[$2]}$0 }; endsnippet -snippet for "for (…) {…}" -for (var ${20:i}=0; ${20:i} < ${1:Things}.length; ${20:i}++) { - ${100:${1:Things}[${20:i}]}$0 +snippet for "for (...) {...}" +for (var ${2:i}=0; $2 < ${1:Things}.length; $2++) { + ${3:$1[$2]}$0 }; endsnippet @@ -47,16 +50,12 @@ function ${1:function_name} (${2:argument}) { } endsnippet -snippet f "function" -function($1) {${0:$TM_SELECTED_TEXT}}; -endsnippet - snippet ife "if ___ else" -if (${1:true}) {${0:$TM_SELECTED_TEXT}} else{}; +if (${1:true}) {$0} else{}; endsnippet snippet if "if" -if (${1:true}) {${0:$TM_SELECTED_TEXT}}; +if (${1:true}) {$0}; endsnippet snippet timeout "setTimeout function"