Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto-indent code in the Atom editor?

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?

like image 762
Anders Avatar asked Mar 24 '14 13:03

Anders


People also ask

How do I set auto indentation in Atom?

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.

How do you indent multiple lines in an Atom?

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.

How do you arrange codes in Atom?

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.

What is auto indent?

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.


1 Answers

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' 
like image 71
Nacho L. Avatar answered Nov 07 '22 06:11

Nacho L.