]> git.r.bdr.sh - rbdr/dotfiles/blame - vim/snippets/javascript.snippets
Add ripgrep vim plugin
[rbdr/dotfiles] / vim / snippets / javascript.snippets
CommitLineData
0d23b6e5
BB
1# Prototype
2snippet proto
3 ${1:class_name}.prototype.${2:method_name} =
4 function(${3:first_argument}) {
5 ${4:// body...}
6 };
7# Function
8snippet fun
9 function ${1:function_name} (${2:argument}) {
10 ${3:// body...}
11 }
12# Anonymous Function
13snippet f
14 function(${1}) {${2}};
15# if
16snippet if
17 if (${1:true}) {${2}}
18# if ... else
19snippet ife
20 if (${1:true}) {${2}}
21 else{${3}}
22# tertiary conditional
23snippet t
24 ${1:/* condition */} ? ${2:a} : ${3:b}
25# switch
26snippet switch
27 switch(${1:expression}) {
28 case '${3:case}':
29 ${4:// code}
30 break;
31 ${5}
32 default:
33 ${2:// code}
34 }
35# case
36snippet case
37 case '${1:case}':
38 ${2:// code}
39 break;
40 ${3}
41# for (...) {...}
42snippet for
43 for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) {
44 ${4:$1[$2]}
45 };
46# for (...) {...} (Improved Native For-Loop)
47snippet forr
48 for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) {
49 ${4:$1[$2]}
50 };
51# while (...) {...}
52snippet wh
53 while (${1:/* condition */}) {
54 ${2:/* code */}
55 }
56# do...while
57snippet do
58 do {
59 ${2:/* code */}
60 } while (${1:/* condition */});
61# Object Method
62snippet :f
63 ${1:method_name}: function(${2:attribute}) {
64 ${4}
65 }${3:,}
66# setTimeout function
67snippet timeout
68 setTimeout(function() {${3}}${2}, ${1:10};
69# Get Elements
70snippet get
71 getElementsBy${1:TagName}('${2}')${3}
72# Get Element
73snippet gett
74 getElementBy${1:Id}('${2}')${3}