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

Ideally, I'd love to be able to do something like this:
x //
f1 //
f2 //
f3 //
f4 //
f5
or if possible, this would be even better:
x
// f1
// f2
// f3
// f4
// f5
For example, using newlines after // results in some really weird indentation:

Ideally, I'd love to be able to do something like this:
x //
f1 //
f2 //
f3 //
f4 //
f5
or if possible, this would be even better:
x
// f1
// f2
// f3
// f4
// f5
You can use InputAutoReplacements with a TemplateBox to achieve the desired behavior:
CurrentValue[EvaluationNotebook[], {InputAutoReplacements,"//"}] = TemplateBox[
{},
"Postfix",
DisplayFunction->("//"&),
InterpretationFunction->("//"&),
SyntaxForm->"\[VerticalSeparator]"
];
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:
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):
A rough approximation using a string
toExpr[str_String] :=
str //
StringReplace[#, "\n" :> ""] & //
ToExpression;
"
x
//f1
//f2
//f3
//f4
//f5
" //
toExpr
f5[f4[f3[f2[f1[x]]]]]
Although, this is just a Composition
Composition[f5, f4, f3, f2, f1]@x
f5[f4[f3[f2[f1[x]]]]]
f5@*f4@*f3@*f2@*f1@x
f5[f4[f3[f2[f1[x]]]]]
% == %% == %%%
True
xon 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,+yis two different expressions and not equivalent tox+, 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 useCodecells which don't indent at all but I don't think that's what you want. – Szabolcs Apr 17 '15 at 17:05x // RightComposition[ f1, f2, f3, f4, f5]can have a relatively good appearance.x // f1 /* f2 /* f3 /* f4 /* f5unfortunately doesn't. – Karsten7 Jul 05 '15 at 10:39//is quite useless. Have you suggested this to Wolfram? – Szabolcs Jul 06 '15 at 12:34