forked from facelessuser/RegReplace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reg_replace.sublime-settings
executable file
·121 lines (112 loc) · 5.66 KB
/
reg_replace.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
////////////////////////////////
// Regex with scope qualifiers//
////////////////////////////////
// Required parameters:
// find: Regex description of what you would like to target.
//
// Optional parameters:
// replace: description of what you would like to replace target with.
// Variables are okay for non-literal searches and are done by escaping
// the selection number \\1 etc. Default value is "\\0".
// literal: Boolean setting to define whether the find and replace is literal or not.
// Default is false.
// greedy: Boolean setting to define whether search is greedy or not. Default is true.
// case: Boolean defining case sensitivity. True equals sensitive. Defualt is true.
// scope_filter: an array of scope qualifiers for the match.
// - 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
//////////////////////////////////////////////////////////////
// Scope search with regex qualifier (also find and replace)//
//////////////////////////////////////////////////////////////
// Required parameters:
// scope: scope you would like to target
//
// Optional parameters:
// find: regex description that is to be applied to the scope
// to qualify. Also can be used to find and replace
// within the found scope. Default is None.
// replace: description of what you would like to replace within the scope.
// Default value is "\\0".
// literal: Boolean setting to define whether the find and replace is literal or not.
// Default is false.
// greedy_replace: Boolean setting to define whether regex search is greedy or not. Default is true.
// greedy_scope: Boolean setting to define whether scope search is greedy or not. Default is true.
// case: Boolean setting to define whether regex search is case sensitive. Default is true.
// multi_pass_regex:Boolean setting to define whether there will be multiple sweeps on the scope region
// region to find and replace all instances of the regex, when regex cannot be formatted
// to find all instances in a greedy fashion. Default is false.
{
"replacements": {
// Example replacements
"html5_remove_deprecated_type_attr": {
"find": "(<(style|script)[^>]*)\\stype=(\"|')text/(css|javascript)(\"|')([^>]*>)",
"replace": "\\1\\6",
"greedy": true,
"case": false
},
// remove_json_dangling_commas
"remove_json_dangling_commas": {
"find": ",([\\r\\n\\s]*)(\\]|\\})",
"replace": "\\1\\2",
"greedy": true,
"scope_filter": ["-string", "-comment"]
},
"remove_html_comments": {
"find": "<!--[\\s\\S]+?-->",
"replace": "",
"scope_filter": ["!comment"],
"greedy": true,
"case": true
},
"remove_trailing_spaces": {
"find": "[ \\t]+$",
"replace": "",
"greedy": true,
"case": true
},
// Delete a comment or comment blocks
"remove_comments": {
"scope": "comment",
"find" : "([^\\n\\r]+)",
"replace": "",
"greedy_replace": true
}
},
// If on_save is true, RegReplace will search through the file patterns listed below right before a file is saved,
// if the file name matches a file pattern, the sequence will be applied before the file is saved.
// RegReplace will apply all sequences that apply to a given file in the order they appear below.
"on_save": false,
// Highlight visual settings
"on_save_highlight_scope": "invalid",
"on_save_highlight_style": "outline",
// on_save replacements
"on_save_sequences": [
// An example on_save event that removes dangling commas from json files
// - file_regex: an array of regex strings that must match the file for the sequence to be applied
// - case: regex case sensitivity (true|false) false is default (this setting is optional)
// - file_pattern: an array of file patterns that must match for the sequence to be applied
// - sequence: an array of replacement definitions to be applied on saving the file
// - multi_pass: perform multiple passes on file to catch all regex instances
{
"file_regex": [".*\\.sublime-(settings|commands|menu|keymap|mousemap|theme|build|project|completions|commands)"],
"file_pattern": ["*.json"],
"sequence": ["remove_json_dangling_commas"]
},
// An example on_save_sequence that targets all files and trims trailing spaces
// - file_pattern: an array of file patterns that must match for the sequence to be applied
// - sequence: an array of replacement definitions to be applied on saving the file
{"file_pattern": ["*"], "sequence": ["remove_trailing_spaces"]}
],
// Show replace results in panel
"results_in_panel": false,
// Maximum sweep threshold for multi-pass
"multi_pass_max_sweeps": 100,
// Color? (scope)
"find_highlight_color": "invalid",
// Highlight style? (outline|solid|underline)
"find_highlight_style": "outline",
// Search under selection(s) if and only if exists
"selection_only": false
}