0

Suppose I have the following line

double dx = r1 < 1 ? sqrt(r1) - 1 : 1 - sqrt(2 - r1);

I press enter and tab at the colon causing Emacs to align like this:

double dx = r1 < 1 ? sqrt(r1) - 1
               : 1 - sqrt(2 - r1);

How can I configure Emacs so that it insteads aligns like this:

double dx = r1 < 1 ? sqrt(r1) - 1
                   : 1 - sqrt(2 - r1);

That is, the colon should be placed at the same column as the question mark.

I want the same alignment in all languages with this syntactic construct; C, C++, Java, JavaScript etc.

  • I imagine you'd have to write a custom line-up function - but maybe somebody has written one for this case already. – NickD Jul 2 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.