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:

  1. It would open a tab in an active VS Code window.
  2. It would allow me to type my long command.
  3. 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.
  4. 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


I could replicate the same erroneous behavior on the natively-available Terminal app.

Has anyone else faced this problem? Could someone help please?

  • 1
    @WinkyCharlie Zsh creates a temporary file, then calls Vscode to edit that file, then once Vscode exits zsh reads the file and deletes it. If Vscode doesn't save the file, zsh has no way to retrieve what you typed. I don't know Vscode so maybe there's something you aren't saying that a Vscode user might be able to guess. Like maybe Vscode used to ask about creating some kind of other file, like a backup or a project file? Commented May 14, 2021 at 19:43

1 Answer 1


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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .