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?
This works for me:
'atom-workspace atom-text-editor':
'ctrl-alt-a': 'editor:auto-indent'
You have to select all with ctrl-a first.
(tested in Ununtu KDE)
There is the option in the menu, under Edit > Lines > Auto Indent or press Cmd + Shift + p, search for Editor: Auto Indent
by entering just "ai"
Note: In KDE ctrl-alt-l
is already globally set for "lock screen" so better use ctrl-alt-i
instead.
You can add a key mapping in Atom:
Add a section there like this one:
'atom-text-editor':
'ctrl-alt-i': 'editor:auto-indent'
If the indention is not working, it can be a reason, that the file-ending is not recognized by Atom. Add the support for your language then, for example for "Lua" install the package "language-lua".
If a File is not recognized for your language:
~/.atom/config.cson
file (by CTRL+SHIFT+p: type ``open config'')add/edit a customFileTypes
section under core
for example like the following:
core:
customFileTypes:
"source.lua": [
"conf"
]
"text.html.php": [
"thtml"
]
(You find the languages scope names ("source.lua", "text.html.php"...) in the language package settings see here)
Package auto-indent exists to apply auto-indent to entire file with this shortcuts :
ctrl+shift+i
or
cmd+shift+i
Package url : https://atom.io/packages/auto-indent
You can just quickly open up the command palette and do it there
Cmd + Shift + p and search for Editor: Auto Indent
:
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'
You could also try to add a key mapping witch auto select all the code in file and indent it:
'atom-text-editor':
'ctrl-alt-l': 'auto-indent:apply'