The command fc will allow visual editing of the previous command. If I change my mind in the editor, how do I stop the command from being executed. In vim, typing q! or q both result in the command being executed and CTRL-C doesn't work either. Is the only option to delete the command in the editor and then wq?
From vi you can type
:cq to exit without saving and with a non-zero return code. In this case the command will not be repeated.
Alternatively, you can usually suspend the editor with ctrl-z which gets you back to the shell without redoing the command. You still have to
fg to restart the editor, but the tmp file will no longer be around, so you can safely quit the editor. Or you can
kill -9 % this suspended editor.
I agree, it could be easier. Of course, you can always edit lines within bash using vi or emacs commands.
Perhaps, an easier way to remember is to delete the command (dd should do) and quit (
ZZ or any other way to quit with saving should do). IMHO,
:cq is quite arcane.