Code indentation: missing shortcut


#1

I have a question regarding indentation in Atom (0.123.0):

Lets assume this is the code in qusestion:

function test() {
alert();
}

  1. Atom has a built-in option in Edit > Lines > Auto Indent
    If I will select the text and run it through the above, it will work
    However, this command does not have a keyboard shortcut.
  • Can I give it shortcut key?
  • Can I make it work by not select the code lines beforehand?
  1. There is the package Auto Indent
    With this package I do not need to select the code lines beforehand. I can simply invoke the command line and select the package command
  • This package has a shortcut shift-cmd-l, but it does not work

#2

Have you taken a look at the Keymaps document? You can find other documentation on the Atom website here:

https://atom.io/docs/latest/


#3

Does not seem to work…

For the Auto Indent package, the Keybindings settings page shows the following.
This shorcut does not work for me regardless:

shift-cmd-I auto-indent:apply Auto Indent .editor

So anyway, I open the keymap.cson file and put the following just for the sake of testing:
'.editor': 'cmd+p': 'auto-indent:apply'

Still does not work.

So now I wanted to add a shortcut for the Edit > Lines > Auto Indent core functionality (which does not have a shortcut by default), but I can’t find it in the list…

And given the experience above, I think it won’t work anyway?


#4

The Editor Auto-indent works for me from the command pallette:

But I don’t know if it depends on the file type/grammar?


#5

Yes, it works from the command palette, but I am looking for a shortcut to either work it, or change the short cut of the Auto Indent package (which has a shortcut, but does not work, even if customizing it).


#6

I don’t know if there is indeed a bug or not with binding keyboard shortcuts, but I found myself moving to a different package altogether - atom beautify.

Thanks anyway…


#7

I don’t know about the auto-indent package, I haven’t used it.

There isn’t a bug with the keyboard shortcuts to my knowledge … other than the AltGr bug, which doesn’t seem to apply to you. You are correct, the following will not work:

'.editor':
'cmd+p': 'auto-indent:apply'

I’m not sure if you looked at the document I linked or not, but the correct format and command would be:

'.editor':
  'cmd-p': 'editor:auto-indent'

The indentation is significant and it must be a hyphen in the keybinding, not a plus.


#8

You’re right. I’m not sure why I put a + there, that’s silly.