For example, using newlines after // results in some really weird indentation:

enter image description here

Ideally, I'd love to be able to do something like this:

x //
f1 //
f2 //
f3 //
f4 //

or if possible, this would be even better:

// f1
// f2
// f3
// f4
// f5
  • 7
    $\begingroup$ The last one is not possible because x on a line by itself is already a complete expression. x// is not a complete expression, so Mathematica will keep reading more from the next time. Similarly, x, newline, +y is two different expressions and not equivalent to x+, newline, y, i.e. x+y. If a line ends with a backslash, Mathematica will keep reading on the next line, but make sure no spaces follow the backslash. This is just a comment, I don't know the answer to your main question. You can use Code cells which don't indent at all but I don't think that's what you want. $\endgroup$
    – Szabolcs
    Commented Apr 17, 2015 at 17:05
  • $\begingroup$ I cannot recall seeing anything that would let us modify this indentation behavior but I like the question. $\endgroup$
    – Mr.Wizard
    Commented May 6, 2015 at 6:21
  • 2
    $\begingroup$ x // RightComposition[ f1, f2, f3, f4, f5] can have a relatively good appearance. x // f1 /* f2 /* f3 /* f4 /* f5 unfortunately doesn't. $\endgroup$
    – Karsten7
    Commented Jul 5, 2015 at 10:39
  • 1
    $\begingroup$ This would make a lot of sense considering all the operator forms introduced in v10. The current indentation behaviour for // is quite useless. Have you suggested this to Wolfram? $\endgroup$
    – Szabolcs
    Commented Jul 6, 2015 at 12:34

2 Answers 2


You can use InputAutoReplacements with a TemplateBox to achieve the desired behavior:

CurrentValue[EvaluationNotebook[], {InputAutoReplacements,"//"}] = TemplateBox[

The key is to change the SyntaxForm to a symbol that doesn't indent in the undesired fashion, which is most operators. However, it is necessary to use a symbol whose parsing precedence is lower than the default parsing precedence of "//".

Here's a portion of the precedence table from the documentation:

enter image description here

The above explains why I chose \[VerticalSeparator]for the SyntaxForm setting. Now, using // produces the following (as an image so you can see it in action):

enter image description here


A rough approximation using a string

toExpr[str_String] := 
  str //
    StringReplace[#, "\n" :> ""] & //

 " //


Although, this is just a Composition

Composition[f5, f4, f3, f2, f1]@x




% == %% == %%%



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.