-
Notifications
You must be signed in to change notification settings - Fork 0
/
reg_replace_rules.sublime-settings
122 lines (105 loc) · 4.35 KB
/
reg_replace_rules.sublime-settings
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
{
/*
name: (str): Rule name. Required.
find: (str): Regular expression pattern or literal string.
Use (?i) for case insensitive. Use (?s) for dotall.
See https://docs.python.org/3.4/library/re.html for more info on regex flags.
Required unless "scope" is defined.
replace: (str - default=r'\0'): Replace pattern.
literal: (bool - default=False): Preform a non-regex, literal search and replace.
literal_ignorecase: (bool - default=False): Ignore case when "literal" is true.
scope: (str): Scope to search for and to apply optional regex to.
Required unless "find" is defined.
scope_filter: ([str] - default=[]): An array of scope qualifiers for the match.
Only used when "scope" is not defined.
- Any instance of scope qualifies match: scope.name
- Entire match of scope qualifies match: !scope.name
- Any instance of scope disqualifies match: -scope.name
- Entire match of scope disqualifies match: -!scope.name
greedy: (bool - default=True): Apply action to all instances (find all).
Used when "find" is defined.
greedy_scope: (bool - default=True): Find all the scopes specified by "scope."
format_replace: (bool - default=False): Use format string style replace templates.
Works only for Regex (with and without Backrefs) and Re (with Backrefs).
See http://facelessuser.github.io/backrefs/#format-replacements for more info.
multi_pass: (bool - default=False): Perform multiple sweeps on the scope region to find
and replace all instances of the regex when regex cannot be formatted to find
all instances. Since a replace can change a scope, this can be useful.
plugin: (str): Define replace plugin for more advanced replace logic.
Only used for regex replaces and replace.
args: (dict): Arguments for 'plugin'.
Only used for regex replaces and replace.
----------------------------------------------------
###### Regex with optional scope qualifiers. ######
- find (required)
- replace
- literal
- literal_ignorecase
- greedy
- scope_filter
- format_replace
- plugin
- args
###### Scope search with regex applied to scope region. ######
- scope (required)
- find
- replace
- literal
- literal_ignorecase
- greedy
- greedy_scope
- format_replace
- multi_pass
- plugn
- args
*/
// Example replacements
"format": "3.0",
"replacements": {
"find_long_lines": {
"find": "^ *(\"\\w+\": )?+\".{143,}"
},
// remove deprecated type attr
"html5_remove_deprecated_type_attr": {
"find": "(?i)(<(style|script)[^>]*)\\stype=(\"|')text/(css|javascript)(\"|')([^>]*>)",
"replace": "\\1\\6",
"greedy": true
},
"move_punctuation_inside_quotes": {
"find": "\\\\u201d([,.])",
"replace": "\\1\\u201d"
},
"move_punctuation_outside_quotes": {
// ! and ? are sometimes part of the quote, and so inside, and sometimes outside
"find": "([:;)])\\\\u201d",
"replace": "\\u201d\\1"
},
// find all non ascii chars
"non_ascii_chars": {
"find": "[[:^ascii:]]+"
},
"remove_jsdoc_hints": {
"find": "^ +\\* @\\w+.*\\n",
"replace": "",
},
// remove_json_dangling_commas
"remove_json_dangling_commas": {
"find": ",([\\r\\n\\s]*)(\\]|\\})",
"replace": "\\1\\2",
"greedy": true,
"scope_filter": ["-string", "-comment"]
},
"remove_extra_spaces": {
"find": "(\\S) +(\\S)",
"replace": "\\1 \\2"
},
"remove_trailing_spaces": {
"find": "(^ +\" *\\S.*?) +</",
"replace": "\\1</"
},
"unescape_apostrophes": {
"find": "\\\\(['\"])",
"replace": "\\1"
},
}
}