Stupid question: indentation



I have select a bunch of lines in a function (in Lisp) and I would like to indent them automagically.

I tried several commands, but I cannot figure out how to get the indentation done.

Is there some obvious thing I should try?

All the best



The command is called “Editor: Auto Indent”. You can find it in the Command Palette.


Thanks for the reply, but what is “Editor: Auto Indent” in the Command Palette supposed to do?

I select a function (i.e., a full code snippet) and then?

Please bear with me.




It is supposed to automatically indent the code according to the rules of the currently selected grammar.


I don’t see that happening. Neither in Lisp nor in C, nor Java. The code remains unchanged and if I try to edit ii non indentation to speak of is performed.



“edit it, no indentation to speak of…”

Sorry. Typing too fast :slight_smile:


Can you describe what exactly you do, what you expect to happen and what actually happens? Steps to reproduce your problem will be a big help in diagnosing what is going wrong rather than me trying to guess out of the myriad things it could be :grinning:


Here is a code snippet in Java

if (foo == 42) { return "Don't panic!" }

If I hit a return right after the open bracket I get

if (foo == 42) {
return "Don't panic!" }

This with and without the Editor: Auto Indent and with or without the Window: Toggle auto indent.

Not even selecting the code and selecting Edit -> Lines -> Autoindent seem to work.

What I expect is to see is

if (foo == 42) {
    return "Don't panic"; }

Is there a way to achieve this? At a minimum with a command based on a selection. While typing would be better.



Is the grammar set to Java?


Yes it is. As it is for the Lisp example and for the C one. I am on a Mac, just in case.



I can’t reproduce the behavior you’re describing using Atom v1.12.7 on Mac OS X 10.12.2. I tried your described repro steps using both the built-in C and Java grammars. I don’t have a Lisp grammar installed and I don’t think your example applies to Lisp anyway :slight_smile:

Do you have the “Auto Indent” setting turned on?


I have the Atomic Soft Tabs set and the Auto Indent set. I can get some behavior improvement for Java and C by making sure I have bracket enclosed blocks. Expression indentation does not seem to work though. The Lisp grammar seems insensitive to the settings.



Just to clarify. This is an expression I’d like to indent.

System.out.println(">>> " + x[0] + "! = " + 42);

What I expect is to hit return before the ‘+’ signs and get the following:

System.out.println(">>> "
		   + x[0]
		   + "! = "
		   + 42);

This is the standard GNU Coding Style -like indentation.

All the best



Atom doesn’t support that kind of indentation out of the box. There may be some packages that offer that though.


Ok. Thanks.

Do you have any suggestion about which packages may provide that?

Happy Holidays