Edit Commands In An Editor

To invoke an editor for a long command, try ctrl-x e (that is holding control key press x then e).

Yesterday, my labmates are discussing all kinds of editors on the way to the cafeteria. Someone said the command line actually can be used as a simple editor. Think about cat followed by whatever content you want to append to a file, edit it throughly and finally redirect it into the file. While it is an interesting idea to use the command line as an editor, it is somehow not practical.
On the opposite, using an editor to edit a command is welcome, especially when the command is long, complex. The shortcut to rapidly switch into an editor mode modifying a command is ctrl-x e. Two highlights of this technique:
✓ any thing you have already put in the command line would not lose, so it is fine to trigger it at the point when you realize the command will go too long;
✓ the editor is customizable by setting the environment variable EDITOR;

Credits

  • TACC - Texas Advanced Computing Center
  • COMMANDLINEFU.COM - An amazing website full of command line gems