You can use the shortcut
Ctrl-x Ctrl-e
to open commands on the command line in an editor. On save and close the command is run.