TIL: Integrate Visual Studio Code with Shell / CLI

Jonas BrΓΈmsΓΈ - Oct 14 '18 - - Dev Community

Up to now I have been using Sublime Text as my preferred editor, before that it was TextMate, before that it was BBEdit and sometimes in between it has been Atom, Komodo, Vim and vi.

I have come really, really excited with Visual Studio Code (code) and most of my programing and text editing is being done using that editor.

Normally I start code from the command line, but today I decided to go all the way a specified
it as the editor to be executed when edits are initiated from other command line tools using the $EDITOR or $VISUAL variable.

export EDITOR="code --wait --new-window"
Enter fullscreen mode Exit fullscreen mode

This mean that for example can edit, complex command line constructs in code using the CTRL-x,
CTRL-e combination.

code has marvellous Git integration, but if you like me sometime work on the command line instead of the editor with your version control tasks, setting the $GIT_EDITOR environment variable can be quite useful.

This might not be necessary, if you have set $EDITOR or $VISUAL as described above (see also: the Git man page), but if you have special command line setting and would like to differenciate, this could be an option and therefor worth a mention.

export GIT_EDITOR="code --wait --new-window"
Enter fullscreen mode Exit fullscreen mode

And now I can edit commit messages and command lines using code and all the other CLI relying on the $EDITOR integration.

References

Hand-picked from my TIL collection.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .