Skip to content

Commit 1fd6d97

Browse files
codeinaboxlpil
authored andcommitted
Updated JS snippets to make use of VISUAL
1 parent 436f137 commit 1fd6d97

File tree

5 files changed

+50
-70
lines changed

5 files changed

+50
-70
lines changed

UltiSnips/javascript.snippets

-12
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,6 @@ ${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) {
3434

3535
endsnippet
3636

37-
snippet for "for (...) {...} (counting up)" b
38-
for (var ${1:i} = 0, ${2:len} = ${3:Things.length}; $1 < $2; $1++) {
39-
${VISUAL}$0
40-
}
41-
endsnippet
42-
43-
snippet ford "for (...) {...} (counting down, faster)" b
44-
for (var ${2:i} = ${1:Things.length} - 1; $2 >= 0; $2--) {
45-
${VISUAL}$0
46-
}
47-
endsnippet
48-
4937
snippet fun "function (fun)" w
5038
function ${1:function_name}(${2:argument}) {
5139
${VISUAL}$0

snippets/javascript-mocha.snippets

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
snippet des "describe('thing', () => { ... })" b
22
describe('${1:}', () => {
3-
${0}
3+
${0:${VISUAL}}
44
});
55
snippet it "it('should do', () => { ... })" b
66
it('${1:}', () => {
7-
${0}
7+
${0:${VISUAL}}
88
});
99
snippet xit "xit('should do', () => { ... })" b
1010
xit('${1:}', () => {
11-
${0}
11+
${0:${VISUAL}}
1212
});
1313
snippet bef "before(() => { ... })" b
1414
before(() => {
15-
${0}
15+
${0:${VISUAL}}
1616
});
1717
snippet befe "beforeEach(() => { ... })" b
1818
beforeEach(() => {
19-
${0}
19+
${0:${VISUAL}}
2020
});
2121
snippet aft "after(() => { ... })" b
2222
after(() => {
23-
${0}
23+
${0:${VISUAL}}
2424
});
2525
snippet afte "afterEach(() => { ... })" b
2626
afterEach(() => {
27-
${0}
27+
${0:${VISUAL}}
2828
});
2929
snippet exp "expect(...)" b
3030
expect(${1:})${0};

snippets/javascript.es6.react.snippets

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ snippet rdp
6161
# Lifecycle Methods
6262
snippet rcdm
6363
componentDidMount() {
64-
${0}
64+
${0:${VISUAL}}
6565
}
6666

6767
# State

snippets/javascript/javascript.es6.snippets

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ snippet imm "import { member } from 'xyz'"
1010
import { ${1} } from '${2}';
1111
snippet cla
1212
class ${1} {
13-
${0}
13+
${0:${VISUAL}}
1414
}
1515
snippet clax
1616
class ${1} extends ${2} {
17-
${0}
17+
${0:${VISUAL}}
1818
}
1919
snippet clac
2020
class ${1} {
2121
constructor(${2}) {
22-
${0}
22+
${0:${VISUAL}}
2323
}
2424
}
2525
snippet foro "for (const prop of object}) { ... }"
@@ -29,23 +29,23 @@ snippet foro "for (const prop of object}) { ... }"
2929
# Generator
3030
snippet fun*
3131
function* ${1:function_name}(${2}) {
32-
${0}
32+
${0:${VISUAL}}
3333
}
3434
snippet c=>
3535
const ${1:function_name} = (${2}) => {
36-
${0}
36+
${0:${VISUAL}}
3737
}
3838
snippet caf
3939
const ${1:function_name} = (${2}) => {
40-
${0}
40+
${0:${VISUAL}}
4141
}
4242
snippet =>
4343
(${1}) => {
44-
${0}
44+
${0:${VISUAL}}
4545
}
4646
snippet af
4747
(${1}) => {
48-
${0}
48+
${0:${VISUAL}}
4949
}
5050
snippet sym
5151
const ${1} = Symbol('${0}');

snippets/javascript/javascript.snippets

+34-42
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,59 @@
22
# prototype
33
snippet proto
44
${1:class_name}.prototype.${2:method_name} = function(${3}) {
5-
${0}
5+
${0:${VISUAL}}
66
};
77
# Function
88
snippet fun
99
function ${1:function_name}(${2}) {
10-
${0}
10+
${0:${VISUAL}}
1111
}
1212
# Anonymous Function
1313
snippet f "" w
1414
function(${1}) {
15-
${0}
15+
${0:${VISUAL}}
1616
}
1717
# Anonymous Function assigned to variable
1818
snippet vaf
1919
var ${1:function_name} = function(${2}) {
20-
${0}
20+
${0:${VISUAL}}
2121
};
2222
# Function assigned to variable
2323
snippet vf
2424
var ${1:function_name} = function $1(${2}) {
25-
${0}
25+
${0:${VISUAL}}
2626
};
2727
# Immediate function
2828
snippet (f
2929
(function(${1}) {
30-
${0}
30+
${0:${VISUAL}}
3131
}(${2}));
3232
# Minify safe iife
3333
snippet ;fe
3434
;(function(${1}) {
35-
${0}
35+
${0:${VISUAL}}
3636
}(${2}))
3737
# self-defining function
3838
snippet sdf
3939
var ${1:function_name} = function (${2:argument}) {
4040
${3}
4141

4242
$1 = function ($2) {
43-
${0}
43+
${0:${VISUAL}}
4444
};
4545
};
4646
# Flow control
4747
# if
48-
snippet if
48+
snippet if "if (condition) { ... }"
4949
if (${1:true}) {
50-
${0}
50+
${0:${VISUAL}}
5151
}
5252
# if ... else
53-
snippet ife
53+
snippet ife "if (condition) { ... } else { ... }"
5454
if (${1:true}) {
55-
${2}
55+
${0:${VISUAL}}
5656
} else {
57-
${0}
57+
${2}
5858
}
5959
# tertiary conditional
6060
snippet ter
@@ -69,25 +69,21 @@ snippet switch
6969
default:
7070
${2}
7171
}
72-
# case
73-
snippet case
72+
snippet case "case 'xyz': ... break"
7473
case '${1:case}':
75-
${2}
74+
${0:${VISUAL}}
7675
break;
77-
${0}
78-
# try
79-
snippet try
76+
snippet try "try { ... } catch(e) { ... }"
8077
try {
81-
${1}
82-
} catch (${2:e}) {
83-
${0:/* handle error */}
78+
${0:${VISUAL}}
79+
} catch (${1:e}) {
80+
${2:/* handle error */}
8481
}
85-
# try finally
86-
snippet tryf
82+
snippet tryf "try { ... } catch(e) { ... } finally { ... }"
8783
try {
88-
${1}
89-
} catch (${2:e}) {
90-
${0:/* handle error */}
84+
${0:${VISUAL}}
85+
} catch (${1:e}) {
86+
${2:/* handle error */}
9187
} finally {
9288
${3:/* be executed regardless of the try / catch result*/}
9389
}
@@ -97,25 +93,21 @@ snippet terr
9793
# return
9894
snippet ret
9995
return ${0:result};
100-
# for loop
101-
snippet for
102-
for (var ${2:i} = 0, l = ${1:arr}.length; $2 < l; $2++) {
103-
var ${3:v} = $1[$2];${0:}
96+
snippet for "for (...) {...}"
97+
for (var ${1:i} = 0, ${2:len} = ${3:Things.length}; $1 < $2; $1++) {
98+
${0:${VISUAL}}
10499
}
105-
# Reversed for loop
106-
snippet forr
107-
for (var ${2:i} = ${1:arr}.length - 1; $2 >= 0; $2--) {
108-
var ${3:v} = $1[$2];${0:}
100+
snippet forr "reversed for (...) {...}"
101+
for (var ${2:i} = ${1:Things.length} - 1; $2 >= 0; $2--) {
102+
${0:${VISUAL}}
109103
}
110-
# While loop
111-
snippet wh
104+
snippet wh "(condition) { ... }"
112105
while (${1:/* condition */}) {
113-
${0}
106+
${0:${VISUAL}}
114107
}
115-
# Do while loop
116-
snippet do
108+
snippet do "do { ... } while (condition)"
117109
do {
118-
${0}
110+
${0:${VISUAL}}
119111
} while (${1:/* condition */});
120112
# For in loop
121113
snippet fori
@@ -126,7 +118,7 @@ snippet fori
126118
# Object Method
127119
snippet :f
128120
${1:method_name}: function (${2:attribute}) {
129-
${3}
121+
${0:${VISUAL}}
130122
},
131123
# hasOwnProperty
132124
snippet has

0 commit comments

Comments
 (0)