├── .python-version
├── Comments.tmPreferences
├── Context.sublime-menu
├── Fold.tmPreferences
├── INI.sublime-syntax
├── LICENSE
├── README.md
├── REG.sublime-syntax
├── RegistryEditorVersion.sublime-completions
├── RegistryHives.sublime-completions
├── Symbols.tmPreferences
├── open_context_reg_key.py
└── syntax_test_ini.ini
/.python-version:
--------------------------------------------------------------------------------
1 | 3.8
--------------------------------------------------------------------------------
/Comments.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | name
5 | Comments
6 | scope
7 | source.ini, source.reg
8 | settings
9 |
10 | shellVariables
11 |
12 |
13 | name
14 | TM_COMMENT_START
15 | value
16 | ;
17 |
18 |
19 | name
20 | TM_COMMENT_START_2
21 | value
22 | #
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Context.sublime-menu:
--------------------------------------------------------------------------------
1 | [
2 | { "caption": "Open Key in regedit.exe", "command": "open_context_reg_key" }
3 | ]
4 |
--------------------------------------------------------------------------------
/Fold.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | scope
5 | source.ini | source.reg
6 | settings
7 |
8 | foldScopes
9 |
10 |
11 | begin
12 | meta.section meta.whitespace.newline
13 | end
14 | meta.section
15 | excludeTrailingNewlines
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/INI.sublime-syntax:
--------------------------------------------------------------------------------
1 | %YAML 1.2
2 | ---
3 | # http://www.sublimetext.com/docs/syntax.html
4 | # https://en.wikipedia.org/wiki/INI_file
5 | name: INI
6 | scope: source.ini
7 |
8 | file_extensions:
9 | - ini
10 | - cfg
11 | - conf
12 |
13 | hidden_file_extensions:
14 | - avpreset
15 | - desktop
16 | - ffpreset
17 | - inf
18 | - lektorproject
19 | - lng
20 | - pycodestyle
21 | - pylintrc
22 | - url
23 | - vlcrc
24 | - .buckconfig
25 | - .coveragerc
26 | - .editorconfig
27 | - .flake8
28 | - .flowconfig
29 | - .hgrc
30 | - .pycodestyle
31 | - .pylintrc
32 | - .style.yapf
33 |
34 | variables:
35 | separator: '[=:]'
36 |
37 | contexts:
38 |
39 | main:
40 | - include: comment
41 | - include: section
42 | - include: mapping
43 |
44 | comment:
45 | - match: ;
46 | scope: punctuation.definition.comment.ini
47 | push:
48 | - meta_scope: comment.line.semicolon.ini
49 | - match: \n
50 | pop: true
51 | - match: \#
52 | scope: punctuation.definition.comment.ini
53 | push:
54 | - meta_scope: comment.line.number-sign.ini
55 | - match: \n
56 | pop: true
57 |
58 | section:
59 | - match: ^\s*(\[)
60 | captures:
61 | 1: punctuation.definition.section.begin.ini
62 | push:
63 | - meta_scope: meta.section.ini
64 | - match: \-?
65 | scope: keyword.operator.arithmetic.ini
66 | set: section-name
67 |
68 | section-name:
69 | - meta_content_scope: meta.section.ini entity.name.section.ini
70 | - match: (\])(\s*$)?
71 | scope: meta.section.ini
72 | captures:
73 | 1: punctuation.definition.section.end.ini
74 | 2: meta.whitespace.newline.ini
75 | pop: true
76 | - match: \.
77 | scope: punctuation.separator.namespace.ini
78 | - match: \\
79 | scope: punctuation.separator.backslash.ini
80 | - match: ':'
81 | scope: punctuation.separator.colon.ini
82 | - include: eol-pop
83 |
84 | mapping:
85 | - match: (?=\S)
86 | push:
87 | - meta_content_scope: meta.mapping.key.ini
88 | - match: (?=\s*{{separator}})
89 | set:
90 | - mapping-value
91 | - mapping-separator
92 | - match: (\[)(\d+)(\])
93 | captures:
94 | 1: punctuation.section.brackets.begin.ini
95 | 2: meta.number.integer.decimal.ini constant.numeric.value.ini
96 | 3: punctuation.section.brackets.end.ini
97 | - match: \,
98 | scope: punctuation.separator.sequence.ini
99 | - include: string
100 | - include: eol-pop
101 |
102 | mapping-separator:
103 | - match: '{{separator}}'
104 | scope: punctuation.separator.key-value.ini
105 | pop: true
106 |
107 | mapping-value:
108 | - meta_content_scope: meta.mapping.ini
109 | - match: \-(?=\s*($|#))
110 | scope: meta.mapping.value.ini keyword.operator.arithmetic.ini
111 | pop: true
112 | - match: (?=\S)
113 | set:
114 | - mapping-value-meta
115 | - maybe-value-firstline
116 | - match: \n
117 | set:
118 | - mapping-value-meta
119 | - maybe-value-multiline
120 |
121 | mapping-value-meta:
122 | - meta_scope: meta.mapping.value.ini
123 | - match: ''
124 | pop: true
125 |
126 | maybe-value-firstline:
127 | - match: (,)\s*$\n?
128 | captures:
129 | 1: punctuation.separator.sequence.ini
130 | set: maybe-value-multiline
131 | - include: constant
132 | - include: number
133 | - include: string
134 | - include: eol-pop
135 |
136 | maybe-value-multiline:
137 | - include: comment
138 | - match: ^(?=\S)
139 | pop: true
140 | - match: (?=.+{{separator}})
141 | pop: true
142 | - match: (,)\s*$\n?
143 | captures:
144 | 1: punctuation.separator.sequence.ini
145 | - include: constant
146 | - include: number
147 | - include: string
148 |
149 | constant:
150 | - match: \b(?i:true)\b
151 | scope: constant.language.boolean.true.ini
152 | - match: \b(?i:false)\b
153 | scope: constant.language.boolean.false.ini
154 | - match: \bdword\b
155 | scope: storage.type.dword.ini
156 | set:
157 | - match: ':'
158 | scope: punctuation.separator.colon.ini
159 | set:
160 | - include: hex-number
161 | - include: eol-pop
162 | - match: \S
163 | scope: invalid.illegal.ini
164 | - include: eol-pop
165 | - match: \S
166 | scope: invalid.illegal.ini
167 | - match: \b(hex\b(?:\([01234578ab]\))?)
168 | scope: storage.type.hex.ini
169 | set:
170 | - match: ':'
171 | scope: punctuation.separator.colon.ini
172 | set:
173 | - include: hex-number
174 | - include: eol-pop
175 | - match: \,
176 | scope: punctuation.separator.sequence.ini
177 | - match: (\\)\s*$
178 | captures:
179 | 1: punctuation.separator.continuation.line.ini
180 | push:
181 | - include: comment
182 | - match: (?=\S)
183 | pop: true
184 | - match: ^\s+
185 | - match: \S
186 | scope: invalid.illegal.ini
187 | - match: '[^()01234578ab\s]'
188 | scope: invalid.illegal.ini
189 |
190 | hex-number:
191 | - match: \b\h+\b
192 | scope: meta.number.integer.hexadecimal.ini constant.numeric.value.ini
193 |
194 | number:
195 | - match: '([-+])?\b(\d*(\.)\d+(?:(?:E|e)[-+]?\d+)?)(F|f)?\b'
196 | scope: meta.number.float.decimal.ini
197 | captures:
198 | 1: keyword.operator.arithmetic.ini
199 | 2: constant.numeric.value.ini
200 | 3: punctuation.separator.decimal.ini
201 | 4: constant.numeric.suffix.ini
202 | - match: '([-+])?\b(\d+)\b'
203 | scope: meta.number.integer.decimal.ini
204 | captures:
205 | 1: keyword.operator.arithmetic.ini
206 | 2: constant.numeric.value.ini
207 |
208 | string:
209 | - match: \"
210 | scope: punctuation.definition.string.begin.ini
211 | push:
212 | - meta_scope: string.quoted.double.ini
213 | - include: character-escape
214 | - match: \"
215 | scope: punctuation.definition.string.end.ini
216 | pop: true
217 | - match: \n
218 | pop: true
219 | - match: \'
220 | scope: punctuation.definition.string.begin.ini
221 | push:
222 | - meta_scope: string.quoted.single.ini
223 | - include: character-escape
224 | - match: \'
225 | scope: punctuation.definition.string.end.ini
226 | pop: true
227 | - match: \n
228 | pop: true
229 | - match: (?=\S)
230 | push:
231 | - meta_content_scope: string.unquoted.ini
232 | - include: character-escape
233 | - match: (?=[\s=:,\[])
234 | pop: true
235 |
236 | character-escape:
237 | - match: \\(?:[^*\s\w]|[abnrt0]|x\h{4})
238 | scope: constant.character.escape.ini
239 |
240 | eol-pop:
241 | - match: $|(?=\s+#)
242 | pop: true
243 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # INI Syntax
2 |
3 | [](https://github.com/jwortmann/ini-syntax/blob/master/LICENSE)
4 | [](https://github.com/jwortmann/ini-syntax/tags)
5 | [](https://github.com/jwortmann/ini-syntax/actions)
6 |
7 | A package for [Sublime Text](https://www.sublimetext.com/) that provides syntax highlighting for INI and related file types like Windows Registry (.reg) files.
8 |
9 | ## Installation
10 |
11 | The package can be installed via Sublime Text's package manager [Package Control](https://packagecontrol.io/installation).
12 | From the command palette choose *Package Control: Install Package* and search for *INI*.
13 |
14 | ## Features
15 |
16 | You can navigate between sections in opened INI files via Sublime's *Goto Symbol...* feature from the menu or with the keyboard shortcut Ctrl+R (⌘+R on macOS).
17 |
18 | ## Customization
19 |
20 | ### Syntax highlighting
21 |
22 | Following the naming conventions for key-value pairs, the scopes `meta.mapping.key.ini string` and `meta.mapping.value.ini string` are applied for keys and string values, respectively.
23 | If you prefer different highlighting colors for key names and values, ensure to use a color scheme which targets one of these scopes to distinguish between them.
24 | You can easily add such a rule as a customization to your color scheme, as described in the [official documentation](https://www.sublimetext.com/docs/color_schemes.html#customization).
25 | For example, if you want keys to be highlighted with the same color as keywords in *Mariana*, create a file `Mariana.sublime-color-scheme` in your Packages/User directory with the following content:
26 | ```json
27 | {
28 | "rules": [
29 | {
30 | "scope": "meta.mapping.key.ini string",
31 | "foreground": "var(pink)"
32 | }
33 | ]
34 | }
35 | ```
36 |
37 | ### Comment toggling
38 |
39 | The default character used by the "toggle comment" functionality (Ctrl+/) in INI files is a semicolon.
40 | If you prefer to use `#` instead, you can achieve that by adding a custom key binding with a `"variant": 2` argument for the `toggle_comment` command (this requires Sublime Text build 4130 or later):
41 | ```json
42 | {
43 | "keys": ["ctrl+/"],
44 | "command": "toggle_comment",
45 | "args": {"block": false, "variant": 2},
46 | "context": [{"key": "selector", "operand": "source.ini"}]
47 | }
48 | ```
49 |
--------------------------------------------------------------------------------
/REG.sublime-syntax:
--------------------------------------------------------------------------------
1 | %YAML 1.2
2 | ---
3 | name: REG
4 | scope: source.reg
5 |
6 | first_line_match: ^(?:REGEDIT4|Windows Registry Editor Version 5\.00)\b
7 |
8 | file_extensions:
9 | - reg
10 |
11 | contexts:
12 | main:
13 | - match: ''
14 | push:
15 | - meta_scope: meta.directive.registry.ini
16 | - match: ^(?:REGEDIT4|Windows Registry Editor Version 5\.00)\b
17 | scope: keyword.other.directive.registry.ini
18 | set: content
19 | - match: \n
20 | set: content
21 | - match: (?=;)
22 | set: content
23 | - include: content
24 |
25 | content:
26 | - include: Packages/INI/INI.sublime-syntax
27 |
--------------------------------------------------------------------------------
/RegistryEditorVersion.sublime-completions:
--------------------------------------------------------------------------------
1 | {
2 | "scope": "source.reg meta.directive.registry",
3 | "completions": [
4 | {
5 | "trigger": "Windows Registry Editor Version 5.00",
6 | "contents": "Windows Registry Editor Version 5.00",
7 | "kind": "ambiguous"
8 | }
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/RegistryHives.sublime-completions:
--------------------------------------------------------------------------------
1 | {
2 | "scope": "source.reg meta.section - meta.whitespace",
3 | "completions": [
4 | {
5 | "trigger": "HKCR",
6 | "contents": "HKEY_CLASSES_ROOT",
7 | "annotation": "HKEY_CLASSES_ROOT",
8 | "kind": ["namespace", "h", "Registry Hive"]
9 | },
10 | {
11 | "trigger": "HKCU",
12 | "contents": "HKEY_CURRENT_USER",
13 | "annotation": "HKEY_CURRENT_USER",
14 | "kind": ["namespace", "h", "Registry Hive"]
15 | },
16 | {
17 | "trigger": "HKLM",
18 | "contents": "HKEY_LOCAL_MACHINE",
19 | "annotation": "HKEY_LOCAL_MACHINE",
20 | "kind": ["namespace", "h", "Registry Hive"]
21 | },
22 | {
23 | "trigger": "HKCC",
24 | "contents": "HKEY_CURRENT_CONFIG",
25 | "annotation": "HKEY_CURRENT_CONFIG",
26 | "kind": ["namespace", "h", "Registry Hive"]
27 | }
28 | ]
29 | }
30 |
--------------------------------------------------------------------------------
/Symbols.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | name
5 | Symbol List
6 | scope
7 | entity.name.section.ini
8 | settings
9 |
10 | showInSymbolList
11 | 1
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/open_context_reg_key.py:
--------------------------------------------------------------------------------
1 | import sublime
2 | import sublime_plugin
3 | import subprocess
4 |
5 |
6 | IS_WINDOWS = sublime.platform() == 'windows'
7 |
8 |
9 | class OpenContextRegKeyCommand(sublime_plugin.TextCommand):
10 | def run(self, edit, event):
11 | pt = self.view.window_to_text((event['x'], event['y']))
12 | regions = self.view.find_by_selector('entity.name.section')
13 | for region in regions:
14 | if region.contains(pt):
15 | startupinfo = subprocess.STARTUPINFO()
16 | startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
17 | startupinfo.wShowWindow = 11 # force minimized window
18 |
19 | reg_key = self.view.substr(region)
20 | subprocess.call('cmd /c REG ADD HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit /v LastKey /t REG_SZ /d "{}" /f && start regedit'.format(reg_key), startupinfo=startupinfo)
21 | break
22 |
23 | def is_enabled(self, event):
24 | return IS_WINDOWS
25 |
26 | def is_visible(self, event):
27 | return self.is_enabled(event) and self.view.match_selector(self.view.window_to_text((event['x'], event['y'])), 'source.reg entity.name.section')
28 |
29 | def want_event(self):
30 | return True
31 |
--------------------------------------------------------------------------------
/syntax_test_ini.ini:
--------------------------------------------------------------------------------
1 | ; SYNTAX TEST "Packages/INI/INI.sublime-syntax"
2 |
3 | ; comment
4 | ;<- punctuation.definition.comment.ini
5 | ;^^^^^^^^ comment.line.semicolon.ini
6 |
7 | # comment
8 | ;<- punctuation.definition.comment.ini
9 | ;^^^^^^^^ comment.line.number-sign.ini
10 |
11 | # comment
12 | ; ^ punctuation.definition.comment.ini
13 | ; ^^^^^^^^^ comment.line.number-sign.ini
14 |
15 | [section]
16 | ;^^^^^^^^^ meta.section.ini
17 | ;<- punctuation.definition.section.begin.ini
18 | ;^^^^^^^ entity.name.section.ini
19 | ; ^ punctuation.definition.section.end.ini
20 | ; ^ meta.whitespace.newline.ini
21 |
22 | [section.subsection]
23 | ;^^^^^^^^^^^^^^^^^^^ meta.section.ini
24 | ;^^^^^^^^^^^^^^^^^^ entity.name.section.ini
25 | ; ^ punctuation.separator.namespace.ini
26 |
27 | [section with spaces]
28 | ;^^^^^^^^^^^^^^^^^^^^ meta.section.ini
29 | ;^^^^^^^^^^^^^^^^^^^ entity.name.section.ini
30 |
31 | [testenv:py38-{x86,x64}-venv]
32 | ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.section.ini
33 | ;^^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.section.ini
34 | ; ^ punctuation.separator.colon.ini
35 |
36 | [-HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}]
37 | ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.section.ini
38 | ;^ keyword.operator.arithmetic.ini - entity.name.section
39 | ; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.section.ini
40 | ; ^ punctuation.separator.backslash.ini
41 | ; ^ punctuation.separator.backslash.ini
42 | ; ^ - keyword.operator
43 |
44 | [section with preceding whitespace]
45 | ;<- meta.section.ini - punctuation
46 | ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.section.ini
47 | ; ^ punctuation.definition.section.begin.ini
48 |
49 | [section # comment
50 | ;^^^^^^^ meta.section.ini
51 | ; ^^^^^^^^^^^ - meta.section
52 | ;<- punctuation.definition.section.begin.ini
53 | ;^^^^^^^ entity.name.section.ini
54 | ; ^ - comment - entity
55 | ; ^ punctuation.definition.comment.ini
56 | ; ^^^^^^^^^^ comment.line.number-sign.ini
57 |
58 | key=value# no comment
59 | ;^^^^^^^^^^^^^^^^^^^^ - meta.mapping meta.mapping
60 | ;^^ meta.mapping.key.ini string.unquoted.ini
61 | ; ^ meta.mapping.ini punctuation.separator.key-value.ini
62 | ; ^^^^^^^^^^^^^^^^^ meta.mapping.value.ini
63 | ; ^^^^^^ string.unquoted.ini
64 | ; ^^ string.unquoted.ini
65 | ; ^^^^^^^ string.unquoted.ini
66 | ; ^^^^^^^^^^^^ - comment
67 |
68 | key=value # comment
69 | ;^^^^^^^^^^^^^^^^^^ - meta.mapping meta.mapping
70 | ;^^ meta.mapping.key.ini string.unquoted.ini
71 | ; ^ meta.mapping.ini punctuation.separator.key-value.ini
72 | ; ^^^^^ meta.mapping.value.ini
73 | ; ^^^^^^^^^^^ - meta.mapping
74 | ; ^^^^^ string.unquoted.ini
75 | ; ^ - comment - string
76 | ; ^ punctuation.definition.comment.ini
77 | ; ^^^^^^^^^ comment.line.number-sign.ini - string
78 |
79 | key = value
80 | ;^^^^^^^^^^ - meta.mapping meta.mapping
81 | ;^^ meta.mapping.key.ini
82 | ; ^^^ - string
83 | ; ^^^ meta.mapping.ini
84 | ; ^ punctuation.separator.key-value.ini
85 | ; ^^^^^ meta.mapping.value.ini
86 |
87 | key: value
88 | ;^^^^^^^^^ - meta.mapping meta.mapping
89 | ;^^ meta.mapping.key.ini
90 | ; ^ meta.mapping.ini punctuation.separator.key-value.ini
91 | ; ^^^^^ meta.mapping.value.ini
92 |
93 | key='string # no comment'
94 | ; ^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value.ini string.quoted.single.ini
95 |
96 | key="string # no comment"
97 | ; ^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value.ini string.quoted.double.ini
98 |
99 | key=abc\ndef\"
100 | ; ^^^^^^^^^^ meta.mapping.value.ini string.unquoted.ini
101 | ; ^^ constant.character.escape.ini
102 | ; ^^ constant.character.escape.ini
103 |
104 | key=..\Path\To\File.txt
105 | ; ^^^^^^^^^^^^^^^^^^^ meta.mapping.value.ini string.unquoted.ini - constant.character.escape
106 |
107 | envlist = py38,
108 | ;^^^^^^^^^^^^^^ - meta.mapping meta.mapping
109 | ; ^^^^^ meta.mapping.value.ini
110 | ; ^^^^ string.unquoted.ini
111 | ; ^ punctuation.separator.sequence.ini - string
112 | pep8,
113 | ; ^^^^^ meta.mapping.value.ini - meta.mapping meta.mapping
114 | ; ^^^^ string.unquoted.ini
115 | ; ^ punctuation.separator.sequence.ini - string
116 | docs
117 | ; ^^^^ meta.mapping.value.ini string.unquoted.ini - meta.mapping meta.mapping
118 |
119 | ignore =
120 | F841
121 | ; ^^^^ meta.mapping.value.ini string.unquoted.ini - meta.mapping.key
122 | E252
123 | W504 # comment
124 | F821
125 | ; ^^^^ meta.mapping.value.ini string.unquoted.ini - meta.mapping.key
126 |
127 | basepython =
128 | py26: python2.6
129 | ; ^^^^ meta.mapping.key.ini string.unquoted.ini - meta.mapping.value
130 | py27: python2.7
131 | py33: python3.3
132 | py34: python3.4
133 |
134 | key=true
135 | ; ^^^^ meta.mapping.value.ini constant.language.boolean.true.ini
136 |
137 | key=True
138 | ; ^^^^ meta.mapping.value.ini constant.language.boolean.true.ini
139 |
140 | key=FALSE
141 | ; ^^^^^ meta.mapping.value.ini constant.language.boolean.false.ini
142 |
143 | key=1234
144 | ; ^^^^ meta.mapping.value.ini meta.number.integer.decimal.ini constant.numeric.value.ini
145 |
146 | key=-1234
147 | ; ^^^^^ meta.mapping.value.ini meta.number.integer.decimal.ini
148 | ; ^ keyword.operator.arithmetic.ini
149 | ; ^^^^ constant.numeric.value.ini
150 |
151 | key=1.234
152 | ; ^^^^^ meta.mapping.value.ini meta.number.float.decimal.ini constant.numeric.value.ini
153 | ; ^ punctuation.separator.decimal.ini
154 |
155 | key=1.234e-2
156 | ; ^^^^^^^^ meta.mapping.value.ini meta.number.float.decimal.ini constant.numeric.value.ini
157 | ; ^ punctuation.separator.decimal.ini
158 |
159 | key=1.234f
160 | ; ^^^^^^ meta.mapping.value.ini meta.number.float.decimal.ini constant.numeric
161 | ; ^^^^^ constant.numeric.value.ini
162 | ; ^ constant.numeric.suffix.ini
163 | ; ^ punctuation.separator.decimal.ini
164 |
165 | key=(X=16.000000,Y=16.000000,Z=16.000000)
166 | ; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value.ini string.unquoted.ini - constant.numeric - punctuation
167 |
168 | key=string.1234.false
169 | ; ^^^^^^^^^^^^^^^^^ meta.mapping.value.ini string.unquoted.ini - constant.numeric - constant.language
170 |
171 | key=string 1234 false
172 | ; ^^^^^^^^^^^^^^^^^ meta.mapping.value.ini
173 | ; ^^^^^^ string.unquoted.ini
174 | ; ^^^^ meta.number.integer.decimal.ini constant.numeric.value.ini
175 | ; ^^^^^ constant.language.boolean.false.ini
176 |
177 | key1,key2,key3=value
178 | ;^^^^^^^^^^^^^ meta.mapping.key.ini
179 | ; ^ punctuation.separator.sequence.ini
180 | ; ^ punctuation.separator.sequence.ini
181 |
182 | key[1]=value
183 | ;^^^^^ meta.mapping.key.ini
184 | ; ^ punctuation.section.brackets.begin.ini
185 | ; ^ meta.number.integer.decimal.ini constant.numeric.value.ini
186 | ; ^ punctuation.section.brackets.end.ini
187 |
188 | key-with-hyphen=value
189 | ;^^^^^^^^^^^^^^ meta.mapping.key.ini string.unquoted.ini
190 |
191 | "Attributes"=dword:f080004d
192 | ;^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.mapping meta.mapping
193 | ;^^^^^^^^^^^ meta.mapping.key.ini string.quoted.double.ini
194 | ; ^ meta.mapping.ini punctuation.separator.key-value.ini - meta.mapping.key - meta.mapping.value
195 | ; ^^^^^^^^^^^^^^ meta.mapping.value.ini
196 | ; ^ - meta.mapping
197 | ; ^^^^^ storage.type.dword.ini
198 | ; ^ punctuation.separator.colon.ini
199 | ; ^^^^^^^^ meta.number.integer.hexadecimal.ini constant.numeric.value.ini
200 |
201 | "Attributes"=dword:f080004d # comment
202 | ;^^^^^^^^^^^ meta.mapping.key.ini string.quoted.double.ini
203 | ; ^ meta.mapping.ini punctuation.separator.key-value.ini - meta.mapping.key - meta.mapping.value
204 | ; ^^^^^^^^^^^^^^ meta.mapping.value.ini
205 | ; ^^^^^^^^^^ - meta.mapping
206 | ; ^^^^^ storage.type.dword.ini
207 | ; ^ punctuation.separator.colon.ini
208 | ; ^^^^^^^^ meta.number.integer.hexadecimal.ini constant.numeric.value.ini
209 | ; ^ - constant - comment
210 | ; ^^^^^^^^^^ comment.line.number-sign.ini
211 |
212 | "Attributes"=dword: # comment
213 | ;^^^^^^^^^^^^^^^^^^ - meta.mapping meta.mapping
214 | ;^^^^^^^^^^^ meta.mapping.key.ini string.quoted.double.ini
215 | ; ^ meta.mapping.ini punctuation.separator.key-value.ini - meta.mapping.key - meta.mapping.value
216 | ; ^^^^^^ meta.mapping.value.ini
217 | ; ^^^^^^^^^^ - meta.mapping
218 | ; ^^^^^ storage.type.dword.ini
219 | ; ^ punctuation.separator.colon.ini
220 | ; ^ - constant - comment
221 | ; ^^^^^^^^^^ comment.line.number-sign.ini
222 |
223 | "Attributes"=hex(2):01,23,45,67,89,ab,cd,ef
224 | ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.mapping meta.mapping
225 | ; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value.ini
226 | ; ^ - meta.mapping
227 | ; ^^^^^^ storage.type.hex.ini
228 | ; ^ punctuation.separator.colon.ini
229 | ; ^^ meta.number.integer.hexadecimal.ini constant.numeric.value.ini
230 | ; ^ punctuation.separator.sequence.ini
231 |
232 |
233 | "Attributes"=hex(2):01,23,45,67,89,ab,cd,ef # comment
234 | ; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value.ini
235 | ; ^^^^^^^^^^^ - meta.mapping
236 | ; ^^^^^^ storage.type.hex.ini
237 | ; ^ punctuation.separator.colon.ini
238 | ; ^^ meta.number.integer.hexadecimal.ini constant.numeric.value.ini
239 | ; ^ punctuation.separator.sequence.ini
240 | ; ^ - comment - constant - punctuaiton
241 | ; ^^^^^^^^^^ comment.line.number-sign.ini
242 |
243 | "Attributes"=-
244 | ;^^^^^^^^^^^^^ - meta.mapping meta.mapping
245 | ; ^ meta.mapping.value.ini keyword.operator.arithmetic.ini
246 | ; ^ - meta.mapping
247 |
248 | "Attributes"=-
249 | 10
250 | ;<- - meta.mapping
251 | ; ^^ - meta.mapping.value - constant
252 |
253 | "Attributes"=- # comment
254 | ;^^^^^^^^^^^^^ - meta.mapping meta.mapping
255 | ; ^ meta.mapping.value.ini keyword.operator.arithmetic.ini
256 | ; ^^^^^^^^^^^ - meta.mapping - keyword
257 | ; ^^^^^^^^^^ comment.line.number-sign.ini
258 |
259 | @="Value"
260 | ;<- meta.mapping.key.ini string.unquoted.ini
261 |
262 | @=hex:25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,00,74,00,25,65,\
263 | ; ^ punctuation.separator.continuation.line.ini
264 | ; another
265 | # comment
266 | # here
267 | 25,
268 | ; ^^ meta.mapping.value.ini meta.number.integer.hexadecimal.ini constant.numeric.value.ini - meta.mapping.key
269 |
270 | @=hex:25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,00,74,00,25,65,\
271 | 00,6c,00,6c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00
272 | ; ^^ meta.mapping.value.ini meta.number.integer.hexadecimal.ini constant.numeric.value.ini - meta.mapping.key
273 |
--------------------------------------------------------------------------------