The CTRL+x+e keyboard shortcut allows you to open your favorite editor, as defined in the $EDITOR
shell environment variable.
This has stopped working for me recently, but I am not sure what changed.
I have $EDITOR
in my .zshrc
set to VS Code like so:
export EDITOR='code'
Previous(Expected) Behavior
Earlier, triggering the above shortcut in zsh
on iTerm2:
- It would open a tab in an active VS Code window.
- It would allow me to type my long command.
- I would then close the tab, VS Code would ask if I wanted to save the file, I would click on No and it would return to the zsh tab with the long command already entered.
- I just had to press the RETURN key then for running the pasted command.
Actual Behavior:
Now, if I follow the same steps as above, the typed command is no longer entered in the zsh shell, even though the VS Code tab closes.
Environment specs:
macOS Big Sur – 11.2.2
VS Code – 1.55.2
iTerm2 – 3.4.4
zsh – 5.8
Note:
I could replicate the same erroneous behavior on the natively-available Terminal app.
Has anyone else faced this problem? Could someone help please?
Best Answer
The
edit-and-execute-command
function triggered with Ctrl-x-e uses a temporary file which gets opened in the defined editor. If you want to use/run your changed command(s) afterwards, you must answer YES if prompted to save the file. Otherwise your changes will be lost.