forked from vim-scripts/_jsbeautify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
117 lines (108 loc) · 2.91 KB
/
README
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
This is a mirror of http://www.vim.org/scripts/script.php?script_id=4063
Another plugin to format your JavaScript source code
I modified the jsbeautify.vim as I need. (Original jsbeautify.vim is here: http://www.vim.org/scripts/script.php?script_id=2727 ) (changes happened on lines 1, 4, 532, 534, 538, 540 and 503(version 2.1))
in version 2.1+
{
a: 'a',
b: 'b'
}
Move the comma after Object's attribute to next line's front.
{
a: 'a'
,b: 'b'
}
There won't be a newline after } , when it's in an Expression. Such as function({},{}).
Example for these 2 changes mentioned above:
⇲
var p_roleMutexGroupListGrid, p_assignedMutexRoleGrid, p_unassignedMutexRoleGrid, p_roleDetailsForm;
var PID = pffp.setPID({}, {
/*若在維護中需要修改權限設置,請到全局配置文件中去修改。*/
roleMutexGroup_query: 101101
,roleMutexGroupMember_query: 101201
,roleMutexGroupMember_assign: 101202
,roleMutexGroupMember_remove: 101203
,roleMutexGroupMember_details: 101204
,role_details: 100805
});
$(function() {
var array1 = [1, 2, 3];
var array2 = [];
for (var i = 0; i <= 3; i++) {
array2.push(i);
}
if ({
a: ''
,b: ''
,c: 2
} === {
b: ''
,c: 2
,a: ''
} && ['', '', 1] == ['', '', 1]) {
pffp.filterPermissionFunc({}, [PID.roleMutexGroup_query], [initRoleMutexGroupGrid])();// There won be a newline after } , when it's in an Expression.
}
});
var initRoleMutexGroupGrid = function() {
p_roleMutexGroupListGrid = pffp.initGrid(null, {
id: 'roleMutexGroupListGrid'
,confId: 'roleMutexGroupListGrid_conf'
,topBtn: true
,passParam: {}
}, RMGGridRowClick); // There won be a newline after } , when it's in an Expression.
}
⇱ END
------------------------------
in versino 2.3+
⇲
var a = [[[{
a: 'a'
}, {
A: 'A'
}], {
b: 'b'
,B: 'B'
}], [{
c: 'c'
}, {
C: 'C'
}], {
d: 'd'
}, {
D: 'D'
}]
⇱
also good for indent fold method:
before 2.3
⇲
var a = {
columns:[{
field:'A'
,label:'A'
}, {
field:'B'
,label:'B'
}]
}
⇱
in version 2.3+
⇲
var a = {
columns:[{
field:'A'
,label:'A'
}, {
field:'B'
,label:'B'
}]
}
⇱
END
This vim-script also works at a low performance:)
vim-jsbeautify : Simple javascript formater base on js-beautify http://www.vim.org/scripts/script.php?script_id=4017(this one looks like the one which can be faster, but I haven't try it. )
usage:
<leader>_ff
or
bind the g:_Jsbeautify() function to any short key you like.
Thanks jsbeautify.vim's author : aj3423 (as the name I know).
(I just a beginner, don't know how to write a complete vim-script file. )