You might be familiar with
sed '/pattern/G'
for inserting a blank line *below* lines matching /pattern/ but sometimes you want to put the blank line *above* the matching line. For that, you can use
sed '/pattern/{x;p;x;}'
It swaps the current space with the (empty) hold-space, prints that blank-line, then swaps them back so the matching line is there to be printed at the end of the cycle.