I find myself again and again using a combination of the gather and aligned environments. So it would be nice to not have to write so much. In particular, it is often only clear after writing the formula, whether it needs splitting.
So the new environment should act like gather, only that when lines are separated by a special symbol/macro (\n for example) they should be put together into an aligned-environment. I tried the following
\documentclass{article}
\usepackage[fleqn]{amsmath}
\newenvironment{multeq}{%
\let\n{\\}
\let\\{\end{aligned}\\\begin{aligned}}
\begin{aligned}
}{%
\end{aligned}
\let\\{\n}
}
\begin{document}
\begin{gather}
\begin{aligned}
S(A) &= (I_{n-k, k}AI_{n-k,k})_{i,j} = (I_{n-k,k})_{i,i}A_{i,j}(I_{n-k,k})_{j,j}\\
&= \begin{cases}A_{i,j}&\begin{aligned}&(i\leq n-k\wedge j\leq n-k)\\\vee&(i>n-k\wedge j>n-k)\end{aligned}\\-A_{i,j}&\text{otherwise}\end{cases}
\end{aligned}\\
\Rightarrow H = S(U(n-k)\times U(k))
\end{gather}
\begin{multeq}
S(A) &= (I_{n-k, k}AI_{n-k,k})_{i,j} = (I_{n-k,k})_{i,i}A_{i,j}(I_{n-k,k})_{j,j}\n
&= \begin{cases}A_{i,j}&\begin{aligned}&(i\leq n-k\wedge j\leq n-k)\n\vee&(i>n-k\wedge j>n-k)\end{aligned}\n-A_{i,j}&\text{otherwise}\end{cases}\\
\Rightarrow H = S(U(n-k)\times U(k))
\end{multeq}
\end{document}
where the output should be 2×

but it gives the error:
! LaTeX Error: There's no line here to end.
l.24 \begin{multeq}
How does this error come about and what is a good way to create such an environment?
So using David’s corrections, and adding gather:
\newenvironment{multeq}{\begin{gather}%
\def\n{\\}%
\def\\{\end{aligned}\\\begin{aligned}}%
\begin{aligned}%
}{%
\end{aligned}%
\end{gather}}
I got
! Paragraph ended before \gather was complete.
So I tried using \Collect@Body from environ:
\def\savebody#1{\def\BODY{#1}}
\usepackage{environ}
\makeatletter
\newenvironment{multeq}{
\def\n{\\}%
\def\\{\end{aligned}\\\begin{aligned}}%
\Collect@Body\savebody
}{\begin{gather}%
\begin{aligned}%
\BODY%
\end{aligned}%
\end{gather}}
\makeatother
But now the redefinition of \\ is ignored. What else could I do?


\let\n{\\}defines\nto be{like\bgroup. You mean\defthere. – David Carlisle Jan 26 at 11:04\nto have the current meaning of\\(the markup around backticks with backslashes and spaces in comments is a bit odd, I had to edit my previous comment a couple of times to get it to display I know what you mean though:-) – David Carlisle Jan 26 at 11:12\let\n\` is a legal assignment but would define\n ` to the wrong thing. – David Carlisle Jan 26 at 11:13:-)– hpesoj626 Jan 27 at 4:33