This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis
If you're wrangling long shell commands, you know that tweaking parameters can be a bit of a pain. Especially when your command spans multiple lines and includes line breaks, you must be careful not to lose your changes. Press one key too much, and you're shuffling through your shell history and your current changes will be gone.
But today I learned that there's hope. If you want to edit an already typed command in your favorite editor, you can press ctrl + x
followed by ctrl + e
.
This combination triggers the so-called edit-and-execute-command
, which then creates a temporary file, opens it in the editor defined in your shell's $EDITOR
variable, and when you save and close this file — your terminal command will be updated. Pretty magical!
If VS Code is your daily driver, I tested the shortcut with EDITOR=code
, but it didn't work on my machine.
Reply to Stefan
This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis

Stefan Judis | Sciencx (2024-09-07T22:00:00+00:00) A shortcut to edit long shell commands in your $EDITOR (#tilPost). Retrieved from https://www.scien.cx/2024/09/07/a-shortcut-to-edit-long-shell-commands-in-your-editor-tilpost/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.