You can enter expressions as
ex:= A + B 
        + C + D;
If you have large substitution rules, you need to enter them as an expression first, and then do the substitution,
rl:= A -> B + C
              + D + E;
substitute(ex, rl)
It is not possible to enter multiline expressions using $...$ notation.