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?
Auto Indent Luckily, Atom has you covered. Select the code and head to Edit > Lines > Auto Indent. This should copy the current indentation on the file to correct your code. To speed this up, I created a custom keyboard shortcut, enabling me to use Ctrl + Cmd + ] at any point.
Use Ctrl + [ to decrease the indentation and Ctrl + ] (which is similar as tab ) to increase the indentation. Same is valid in other editors as well.
Format a selection of code using the code-format:format-code ( CTRL+SHIFT+C ) command. (Also accessible via context menu, or "Edit > Text > Format Code"). When no selection is provided, the entire file is formatted.
Automatic indenting occurs when you insert new lines. • None No special indenting occurs. Source Insight will return the insertion point to the very beginning of the next line when you insert a new line or word wrap.
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With