I’ve been switching editors back and forth for a while now. In the terminal, I finally started to take a closer look at (neo)vim 🤓, but I’m still not anywhere near my productivity level I currently have in IDEs like Visual Studio Code. So depending on the environment I’m currently working in and the editing task at hand, it’s sometimes a wild mix of nano, (neo)vim, Sublime Text and Visual Studio Code.
When I’m working on a project in VS Code, I prefer using its internal terminal window so everything is in one place. And some command-line tools open a new editor (e.g. for git commit messages) relying on the
EDITOR environment variable, which is set to
vim in my case. But opening one editor in the integrated terminal window of another feels a bit odd and is quite inconvenient if the terminal window is too small.
Luckily there is a workaround for that in VS Code. Open the
settings.json file and add the following lines:
// If you’re running macOS, use "terminal.integrated.env.osx" instead.
"EDITOR": "code --wait",
"GIT_EDITOR": "code --wait"
And depending on which shell you use, add these lines to either
# Only set and export EDITOR and GIT_EDITOR env variables if they have been empty.
[ -z "$EDITOR" ] && export EDITOR=vim
[ -z "$GIT_EDITOR" ] && export GIT_EDITOR=vim
So in your normal terminal, the default
EDITOR will be vim, but inside VS Code’s terminal, a new tab will be opened in your current workspace instead.