我正在使用Meteor平台进行开发,而且这个令人讨厌的错误有时将关闭的大括号插入错误的位置。例如:
<section>
{{#if isConditionTrue}}
{{|
{{> templateName}}
}
}
{{/if}}
</section>
|
代表光标的位置。
输入{{
它应该看起来像这样:
<section>
{{#if isConditionTrue}}
{{|}}
{{> templateName}}
{{/if}}
</section>
但由于这个原因:{{> templateName}}
,sublime文本试图完全包装该子花括号语句。
有关如何解决此问题的任何建议?
我试图使用一个片段希望我可以覆盖默认行为,但没有运气。我也尝试了一下键盘绑定,但也没有运气。
更新 我刚刚在我的默认sublime keymap文件中找到了这个,我不太确定如何修改这些而不会搞乱我的js文件的包装:
// Auto-pair curly brackets
{ "keys": ["{"], "command": "insert_snippet", "args": {"contents": "{$0}"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|$)", "match_all": true }
]
},
{ "keys": ["{"], "command": "wrap_block", "args": {"begin": "{", "end": "}"}, "context":
[
{ "key": "indented_block", "match_all": true },
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_match", "operand": "^$", "match_all": true },
]
},
{ "keys": ["{"], "command": "insert_snippet", "args": {"contents": "{${0:$SELECTION}}"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
]
},
更新#2
我从默认的keybindings文件中获取以下内容,将其复制到我的用户密钥绑定文件,并将"operand": true
更改为"operand": false
,这似乎阻止了包装。
{ "keys": ["{"], "command": "wrap_block", "args": {"begin": "{", "end": "}"}, "context":
[
{ "key": "indented_block", "match_all": true },
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_match", "operand": "^$", "match_all": true },
]
},
但它影响了我的js文件中条件的自动包装。因此,如果我尝试包装并且没有括号的现有条件。
所以如果我试着把它包起来:
if (condition)
console.log('dkslfds');
我明白了:
if (condition) {}
console.log('dkslfds');
虽然不是很大的交易,如果必须,我可以没有这个。
更新#3 这是我的包控件设置文件:
{
"bootstrapped": true,
"in_process_packages":
[
],
"installed_packages":
[
"42 Headers",
"AAAPackageDev",
"Abacus",
"All Autocomplete",
"Autoprefixer",
"Babel",
"Emmet",
"ES6-Toolkit",
"Git",
"GitGutter",
"Handlebars",
"HTML5",
"HTMLAttributes",
"Jade",
"JavaScript & NodeJS Snippets",
"JavaScriptNext - ES6 Syntax",
"JSCS-Formatter",
"LESS",
"One Dark Color Scheme",
"Package Control",
"SCSS",
"SideBarEnhancements",
"Stino",
"Stylus",
"Stylus-Snippets",
"SublimeLinter",
"SublimeLinter-jscs",
"Terminal",
"Theme - Brogrammer",
"Theme - Flatland",
"Theme - Spacegray",
"TodoReview",
"WordPress"
],
"repositories":
[
"https://github.com/gepd/Stino/tree/new-stino"
]
}