My favorites
▼
|
Sign in
yy-vimscript
My Vim scripts, e.g. .vimrc, .ctags, colorscheme, snippets
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
snippets
/
javascript.snippets
r33
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Prototype
snippet proto
/**
* ${5:function intro}
* @param {${6:type}} ${7:$2}
* @return ${8}
*/
${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) {
${4:// body...}
};
# Function
snippet fun
/**
* ${4:function intro}
* @param {${5:type}} ${6:$2}
* @return ${7}
*/
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 ${1:i} = 0, ${2:l} = ${3:Things}.length; $1 < $2; $1${4:++}) {
${5:$3[$1]}
}
# 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 */})
# try/catch
snippet try
try{
${1://code}
}catch(ex){${2}}
# Object Method
snippet :f
/**
* ${5:function intro}
* @param {${6:type}} ${7:$2}
* @return ${8}
*/
${1:method_name}: function(${2:attribute}) {
${4}
}${3:,}
# setTimeout function
snippet settimeout
${3:var timer = }setTimeout(function(){
${2}
}, ${1:10});
# setInterval function
snippet setinterval
${3:var timer = }setInterval(function(){
${2}
}, ${1:10});
# Get Elements
snippet get
getElementsBy${1:TagName}('${2}')${3}
# Get Element
snippet gett
getElementBy${1:Id}('${2}')${3}
snippet $
$(${1:"selector"}).${2:method}(${3})${4}
snippet $(
$(function(){
${1://code}
});
snippet $.each
$.each(${1:array|object}, function(${2:o}){
${3:this}
});
snippet /*
/**
* ${1:Describe what this method does}
* @param {${2:String|Object|Array|Boolean|Number}} ${3:paramName} ${4:Describe this parameter}
* @returns ${5:Describe what it returns}
*/
snippet bug
console.${1:log}(${2});
snippet single
/**
* ${7:Describe what this singleton object does}
* @param {${8:String|Object|Array|Boolean|Number}} ${9:paramName}
* @returns
*/
var ${1:Singleton} = (function(){
${2}
return {
${3:publicMethod}: function(${5:opt}) {
${4://code}
}${6:,}
};
})();
snippet module
/**
* ${5:Describe what this module does}
* @param {object} ${6:paramName}
*/
var ${1:classname} = (function(){
var $1Object = {
${2:privateMethod1}: function(){
},
${3:privateMethod2}: function(){
}
};
return function(opt){
var publicObj = {
options: {},
$2: $1Object.$2,
$3: $1Object.$3${4:,}
};
$.extend(publicObj.options, opt);
return publicObj;
};
})();
Show details
Hide details
Change log
r2
by dexter.yy on Jun 6, 2009
Diff
add
Go to:
/trunk/after
/trunk/after/plugin
/trunk/after/plugin/snipMate.vim
/trunk/autoload
/trunk/autoload/snipMate.vim
/trunk/colors
/trunk/colors/blackboard.vim
/trunk/colors/yytextmate.vim
/trunk/doc
/trunk/doc/HTML.txt
/trunk/doc/NERD_commenter.txt
/trunk/doc/NERD_tree.txt
/trunk/doc/bufexplorer.txt
/trunk/doc/fuzzyfinder.jax
/trunk/doc/fuzzyfinder.txt
/trunk/doc/matchit.txt
/trunk/doc/project.txt
/trunk/doc/snipMate.txt
/trunk/doc/surround.txt
/trunk/doc/taglist.txt
/trunk/doc/tags
/trunk/doc/tags-ja
/trunk/doc/vcscommand.txt
/trunk/doc/winmanager.txt
/trunk/ftplugin
/trunk/ftplugin/css
/trunk/ftplugin/html
...plugin/html/html_snip_helper.vim
/trunk/ftplugin/javascript
/trunk/ftplugin/python
/trunk/indent
...k/indent/IndentAnything_html.vim
/trunk/indent/javascript.vim
/trunk/indent/python.vim
/trunk/plugin
/trunk/plugin/IndentAnything.vim
/trunk/plugin/NERD_commenter.vim
/trunk/plugin/NERD_tree.vim
/trunk/plugin/bufexplorer.vim
/trunk/plugin/fuzzyfinder.vim
/trunk/plugin/javaScriptLint.vim
/trunk/plugin/matchit.vim
/trunk/plugin/snipMate.vim
/trunk/plugin/supertab.vim
/trunk/plugin/taglist.vim
/trunk/plugin/tasklist.vim
/trunk/plugin/vcscommand.vim
/trunk/plugin/vcscvs.vim
/trunk/plugin/vcsgit.vim
/trunk/plugin/vcssvk.vim
Sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 2968 bytes, 164 lines
View raw file
Powered by
Google Project Hosting