How to auto-indent code in the Atom editor?

Anders picture Anders · Mar 24, 2014 · Viewed 392.4k times · Source

How do you auto-indent your code in the Atom editor? In other editors you can usually select some code and auto-indent it.

Is there a keyboard shortcut as well?

Answer

Nacho L. picture Nacho L. · Mar 26, 2014

I found the option in the menu, under Edit > Lines > Auto Indent. It doesn't seem to have a default keymap bound.

You could try to add a key mapping (Atom > Open Your Keymap [on Windows: File > Settings > Keybindings > "your keymap file"]) like this one:

'atom-text-editor':
  'cmd-alt-l': 'editor:auto-indent'

It worked for me :)


For Windows:

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