如何在Atom编辑器中自动缩进代码?在其他编辑器中,您通常可以选择一些代码并自动缩进。

还有快捷键吗?


当前回答

您可以快速打开命令面板并在那里执行 Cmd + Shift + p搜索编辑器:自动缩进:

其他回答

Ctrl+Shift+i worked for me in PHP under Windows ... but some files did not react. Not being the brightest it took me a while to work out that it was the include files that were the problem. If you are using echo(' ... PHP ...') then the PHP does not get re-formatted. To get over this, create a temporary PHP file, say t.php, copy the PHP part into that, reindent it (Ctrl+Shift+i ... did I mention that?) and then copy the newly reformatted PHP back into the original file. Whilst this is a pain, it does give you correctly formatted PHP.

这对我来说很管用:

'atom-workspace atom-text-editor':
    'ctrl-alt-a': 'editor:auto-indent'

你必须先用ctrl-a选择所有。

你也可以尝试添加一个键映射来自动选择文件中的所有代码并缩进它:

'atom-text-editor':
  'ctrl-alt-l': 'auto-indent:apply'

如果你有热键的问题,尝试打开键绑定解析器窗口Cmd + ..它会实时显示你正在按的键。

例如,Cmd + Shift + '实际上是Cmd + "

您可以快速打开命令面板并在那里执行 Cmd + Shift + p搜索编辑器:自动缩进: