g/foo/c\
 change1\
. \
a\
 append1\
.\
1d
.=
w
