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

还有快捷键吗?


当前回答

这对我来说很管用:

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

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

其他回答

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

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

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.

Package auto-indent的存在是为了通过以下快捷方式对整个文件应用自动缩进:

ctrl + shift + i

or

CMD+移位+I

软件包网址:https://atom.io/packages/auto-indent

我更喜欢使用原子美化,CTRL+ALT+B(在linux中,也可能在windows中)处理更好的各种格式,它也是自定义每个文件格式。

更多详情请访问:https://atom.io/packages/atom-beautify

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

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