[英]Sublime Text 3 indents an extra tab after hitting enter for only parentheses in javascript
Right now, I am working on a project using ReactJS in Sublime Text. 现在,我正在使用Sublime Text中的ReactJS开发一个项目。 Whenever I hit enter in between the parentheses it would break to another line and add an extra space.
每当我点击括号之间的输入时,它会断开到另一条线并添加一个额外的空间。 Here's an example:
这是一个例子:
Initial Start 初始开始
The cursor is in the middle, then I hit enter: 光标在中间,然后我按下回车:
Current Result 目前的结果
Then it adds this extra indent afterwards. 然后它会在之后添加这个额外的缩进。 Causing me to waste time and fix it.
让我浪费时间并修复它。
Desired Result 期望的结果
This is my desired result after hitting enter: 点击输入后,这是我想要的结果:
Thank you in advance! 先感谢您!
Open Preferences -> Key Bindings-User
and add the following: 打开
Preferences -> Key Bindings-User
并添加以下内容:
{ "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n\t$0\n"}, "context":
[
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\($", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\)", "match_all": true }
]
}
If the file was previously empty, add square brackets [ ]
around the key binding and save. 如果文件以前是空的,则在键绑定周围添加方括号
[ ]
并保存。 If the file has other custom key bindings, paste it at the beginning just after the opening bracket [
, and make sure you add a comma ,
after it to make sure the file is valid JSON . 如果文件中有其他自定义键绑定,将其粘贴在刚刚开幕括号后开始
[
,并确保你添加一个逗号,
后以确保该文件是有效的JSON 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.