DEV Community

TIL: Integrate Visual Studio Code with Shell / CLI

Jonas Brømsø on October 14, 2018

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...
Collapse
 
jonasbn profile image
Jonas Brømsø

I made a little experiment this morning, exchanging $EDITOR for $VISUAL and it works as expected.

I guess the recommendation should be to use $VISUAL for you GUI enabled editor and then define $EDITOR point to a non-gui like vi, nano, vim or similar for hosts where you access via ssh.

Which makes your shell configuration portable, which holds a lot of benefits.

So I ended up with the following:

VISUAL='code --wait --new-window'
EDITOR='/usr/bin/vi'

export VISUAL EDITOR

Thanks for the pointer. I do however wonder where this is documented, would love to know a know authoritative resource. I will update my TIL accordingly.

Collapse
 
chenge profile image
chenge

On mac, start code in bash.


ln -s /Applications/Visual\ Studio\ Code.app/ codeapp
open codeapp

Collapse
 
jonasbn profile image
Jonas Brømsø

You can also use the official approach, described here: code.visualstudio.com/docs/setup/mac.

As always, and luckily, there is more than one way to do it :-)

Collapse
 
chenge profile image
chenge

Cool, more simple. thanks. :)

 
jonasbn profile image
Jonas Brømsø

I find your recommendation much more correct, the more I think about it - thanks again.

My .bash_profile has followed me for many years, glad to learn that I can still improve it.

Collapse
 
pratham15541 profile image
Pratham

How to do in windows ?