在 Sublime text 2 中缩进代码? [英] Indenting code in Sublime text 2?

查看:34
本文介绍了在 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?

推荐答案

你可以在EditLineReindent中找到,但是默认情况下它没有快捷方式.您可以通过转到菜单PreferencesKeybindingsUser 添加快捷方式,然后在那里添加:

You can find it in EditLineReindent, but it does not have a shortcut by default. You can add a shortcut by going to the menu PreferencesKeybindingsUser, then add there:

{ "keys": ["f12"], "command": "reindent", "args": {"single_line": false} }  

(使用 F12 键实现该功能的示例)

(example of using the F12 key for that functionality)

配置文件使用 JSON 语法,因此这些大括号必须以逗号分隔放置在默认情况下的方括号中.如果您还没有任何其他键绑定,那么您的整个 KeybindingsUser 文件当然看起来像这样:

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 KeybindingsUser file would look like this, of course:

[
    { "keys": ["f12"], "command": "reindent", "args": {"single_line": false}}
]

这篇关于在 Sublime text 2 中缩进代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆