在 Sublime text 2 中缩进代码? [英] Indenting code in Sublime text 2?
问题描述
在 Visual Studio 中,我可以按 Ctrl+K+D 来缩进所有内容,以便代码结构良好且可读.Sublime 2 有没有捷径可以做同样的事情?
In Visual Studio I can press Ctrl+K+D to indent everything so the code is structured nicely and readable. Is there a shortcut in Sublime 2 to do the same?
推荐答案
你可以在Edit
→Line
→Reindent
中找到,但是默认情况下它没有快捷方式.您可以通过转到菜单Preferences
→ Keybindings
→ User
添加快捷方式,然后在那里添加:
You can find it in Edit
→ Line
→ Reindent
, but it does not have a shortcut by default.
You can add a shortcut by going to the menu Preferences
→ Keybindings
→ User
, then add there:
{ "keys": ["f12"], "command": "reindent", "args": {"single_line": false} }
(使用 F12 键实现该功能的示例)
(example of using the F12 key for that functionality)
配置文件使用 JSON 语法,因此这些大括号必须以逗号分隔放置在默认情况下的方括号中.如果您还没有任何其他键绑定,那么您的整个 Keybindings
→ User
文件当然看起来像这样:
The config files use JSON-syntax, so these curly braces have to be placed comma-separated in the square-brackets that are there by default. If you don't have any other key-bindings already, then your whole Keybindings
→ User
file would look like this, of course:
[
{ "keys": ["f12"], "command": "reindent", "args": {"single_line": false}}
]
这篇关于在 Sublime text 2 中缩进代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!