Difference between revisions of "VS Code"

(Working remotely on another server)
(Connect to another server)
 
(5 intermediate revisions by 2 users not shown)
Line 7: Line 7:
  
 
= Working remotely on another server =
 
= Working remotely on another server =
It is relatively easy to work on a remote server with VS Code '''IF''' the OS running on the server isn't too old. It works without a problem on Gadi but it will not work on Accessdev.
+
It is relatively easy to work on a remote server with VS Code '''if''' the OS running on the server isn't too old. It works without a problem on Gadi but it will not work on Accessdev currently.
  
 
== Install the Remote Development extension ==
 
== Install the Remote Development extension ==
Line 13: Line 13:
  
 
== Connect to another server ==
 
== Connect to another server ==
To connect to another server click on the '><' symbol on the bottom left corner of the window. Select “Connect Current Window to Host”. If your SSH config file is set up, you will be provided with a choice of hosts to connect to, else choose “Add New SSH Host” and enter the SSH command you normally use.
+
To connect to another server click on the '><' symbol on the bottom left corner of the window. Select “Connect Current Window to Host”. If your SSH config file is set up, you will be provided with a choice of hosts to connect to, else choose “Add New SSH Host” and enter the SSH command you normally use. To learn more about SSH config files and SSH keys, please check our [https://www.youtube.com/watch?v=AcP2FEFywXA&t=1s SSH training]
  
 +
===Windows users===
 
If you're using Windows and have [https://docs.microsoft.com/en-us/windows/wsl/install-win10 Windows Subsystem for Linux] installed there's also an option to connect to WSL here
 
If you're using Windows and have [https://docs.microsoft.com/en-us/windows/wsl/install-win10 Windows Subsystem for Linux] installed there's also an option to connect to WSL here
 +
 +
Also on Windows, if using the default SSH implementation you need to specify the 'ecdsa' key type when creating a SSH key. In Powershell run
 +
<syntaxhighlight>
 +
ssh-keygen -t ecdsa -b 521 -f .ssh/id_ecdsa
 +
ssh-add
 +
</syntaxhighlight>
 +
and copy the contents of .ssh/id_ecdsa.pub on your computer to Gadi's ~/.ssh/authorized_keys file
  
 
= Extensions =
 
= Extensions =

Latest revision as of 00:26, 9 November 2020

Installation

Even if you only want to use VS Code to work on Gadi, you will first need to install it on your own machine.

Go to code.visualstudio.com and download the package for your system. Follow the installation steps of the installer.

Once you open VS Code, the Welcome editor has a lot of useful links to learn your ways around the editor. It is a good idea to spend a bit of time on those.

Working remotely on another server

It is relatively easy to work on a remote server with VS Code if the OS running on the server isn't too old. It works without a problem on Gadi but it will not work on Accessdev currently.

Install the Remote Development extension

In VS Code, in the Extension tab, search for "Remote Development". Install the extension pack that includes Remote - WSL, Remote - SSH and Remote - Containers. Reload VS Code.

Connect to another server

To connect to another server click on the '><' symbol on the bottom left corner of the window. Select “Connect Current Window to Host”. If your SSH config file is set up, you will be provided with a choice of hosts to connect to, else choose “Add New SSH Host” and enter the SSH command you normally use. To learn more about SSH config files and SSH keys, please check our SSH training

Windows users

If you're using Windows and have Windows Subsystem for Linux installed there's also an option to connect to WSL here

Also on Windows, if using the default SSH implementation you need to specify the 'ecdsa' key type when creating a SSH key. In Powershell run

ssh-keygen -t ecdsa -b 521 -f .ssh/id_ecdsa
ssh-add

and copy the contents of .ssh/id_ecdsa.pub on your computer to Gadi's ~/.ssh/authorized_keys file

Extensions

VS Code comes with a lot of extensions. You will likely want to download one or two extensions per programming language you use. If you are going to work on a remote server, these will need to be installed on the server. You need to connect your window to the server first, then install the extensions. We’ll list below the ones that are most likely to be useful to you but feel free to look for more.

Programming languages

  • Python
  • Modern Fortran
  • Fortran IntelliSense: you’ll need to install fortran-language-server first using pip in a terminal on the server. See the instructions on the Github page linked before.
  • Matlab: not tested
  • R: not tested
  • Bash Beautify

Git

  • GitLens
  • Git Graph