Today I leared about ctrl-x ctrl-e
.
Press it while on the command line to write a (complex) command in your $EDITOR
.
After you are done editing the command you'll be brought back to the command line with the command you just wrote ready to be fired.
A similar functionality is offered by fc
.
With fc
you can edit and run commands from your history.
By the way, commandlinefu has more command line tricks worth checking out.