]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/snippets/javascript.snippets

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

check in snipmate 0.83
[etc/vim.git] / .vim / snippets / javascript.snippets
diff --git a/.vim/snippets/javascript.snippets b/.vim/snippets/javascript.snippets
new file mode 100644 (file)
index 0000000..51f5e05
--- /dev/null
@@ -0,0 +1,74 @@
+# Prototype
+snippet proto
+       ${1:class_name}.prototype.${2:method_name} =
+       function(${3:first_argument}) {
+               ${4:// body...}
+       };
+# Function
+snippet fun
+       function ${1:function_name} (${2:argument}) {
+               ${3:// body...}
+       }
+# Anonymous Function
+snippet f
+       function(${1}) {${2}};
+# if
+snippet if
+       if (${1:true}) {${2}};
+# if ... else
+snippet ife
+       if (${1:true}) {${2}}
+       else{${3}};
+# tertiary conditional
+snippet t
+       ${1:/* condition */} ? ${2:a} : ${3:b}
+# switch
+snippet switch
+       switch(${1:expression}) {
+               case '${3:case}':
+                       ${4:// code}
+                       break;
+               ${5}
+               default:
+                       ${2:// code}
+       }
+# case
+snippet case
+       case '${1:case}':
+               ${2:// code}
+               break;
+       ${3}
+# for (...) {...}
+snippet for
+       for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) {
+               ${4:$1[$2]}
+       };
+# for (...) {...} (Improved Native For-Loop)
+snippet forr
+       for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) {
+               ${4:$1[$2]}
+       };
+# while (...) {...}
+snippet wh
+       while (${1:/* condition */}) {
+               ${2:/* code */}
+       }
+# do...while
+snippet do
+       do {
+               ${2:/* code */}
+       } while (${1:/* condition */});
+# Object Method
+snippet :f
+       ${1:method_name}: function(${2:attribute}) {
+               ${4}
+       }${3:,}
+# setTimeout function
+snippet timeout
+       setTimeout(function() {${3}}${2}, ${1:10};
+# Get Elements
+snippet get
+       getElementsBy${1:TagName}('${2}')${3}
+# Get Element
+snippet gett
+       getElementBy${1:Id}('${2}')${3}