在Visual Studio中,我可以按Ctrl+K+D来缩进所有内容,因此代码结构很好,易于阅读。在Sublime 2中有捷径可以做到这一点吗?


当前回答

似乎没有人喜欢mac重缩进,所以我是这样做的:

[
   { "keys": ["command+shift+i"], "command": "reindent"}
]

在Preferences中> Key Binding -用户

还有一个额外的建议: 添加

{ "keys": ["command+0"], "command": "focus_side_bar" }

要有侧边栏文件树视图导航使用键盘。

注意: 如果您有多个{}对象集,则在每个{}的末尾添加

其他回答

你可以在编辑→行→再缩进中找到它,但默认情况下它没有快捷键。 你可以通过菜单Preferences→Keybindings→User添加快捷方式,然后添加:

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

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

配置文件使用json语法,因此这些花括号必须在默认的方括号中以逗号分隔。如果你没有任何其他的键绑定,那么你的整个Keybindings→User文件将看起来像这样,当然:

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

代码格式化程序。

使用简单。


1.安装


2.按下ctrl + alt + f(默认)


这是它。

你可以通过菜单Preferences→Keybindings→User添加快捷方式,然后添加:

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

对于那些喜欢IntelJ IDEA的默认键绑定的人,选择Preferences > Settings -用户:

并粘贴下面的命令,有命令+ shift + l快捷方式自动缩进:

[
   { "keys": ["command+shift+l"], "command": "reindent"}
]

reindent命令只对当前选中的行起作用,除非"single_line"参数设置为false。

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

现在,按f12将重新缩进整个文档。