-
Notifications
You must be signed in to change notification settings - Fork 2
3. VSCode & extensions
Yaniv Carmel edited this page Apr 5, 2022
·
28 revisions
In this section, you'll install and configure Visual Studio Code (VSCode), an open-source IDE we love :)
- Download & install Visual Studio Code.
If you're working with WSL:
- Go to Extensions (Ctrl+Shift+X) and install "Remote-WSL". Wait for it to complete.
- Open the Command Palette (Ctrl+Shift+P). This is a useful shortcut that provides access to many VSCode commands. Type and choose "Remote-WSL: New WSL Windows". Wait for it to complete (make sure it says "WSL: Ubuntu" at the bottom-left of the window).
If you're working with a virtual machine:
- Go to Extensions (Ctrl+Shift+X) and install "Remote-SSH". Wait for it to complete.
- Open the Command Palette (Ctrl+Shift+P). This is a useful shortcut that provides access to many VSCode commands. Type and choose "Remote-SSH: Connect to Host...", then "Add new SSH host", and then
ssh <username>@<vm-ip>. Wait for it to complete (make sure it says "SSH: vm-ip" at the bottom-left of the window).
- Go to Extensions (Ctrl+Shift+X) and install "C/C++ Extension Pack". Wait for it to complete.
- Open the VSCode Terminal (Ctrl+Shift+`) and run these commands. Put the email you signed up to GitHub with.
git config --global user.email "you@example.com"
git config --global user.name "Your Name"- Go to Source Control (Ctrl+Shift+G), and choose "Clone Repository", and then "Clone from GitHub". Sign in.
- Open the Command Palette (Ctrl+Shift+P), type "Clone from GitHub", then copy and paste your repository link from GitHub, as shown in the image.

- You'll be asked where you'd like to clone your repository to. Choose
/home/<your username>. Open your project folder in VSCode.
Now that you have cloned the repository, let's practice making another contribution to the project, this time using VSCode. We'll install and configure Clang-Format, an extension that will automatically format your files when you save them.
- Install the "Clang-Format" extension.
- Go to File -> Preferences -> Settings. Search for the setting "Default Formatter" and set it to "Clang-Format", then search for the setting "Format On Save" and enable it.
- Download .clang-format, put it in your project directory and upload it to GitHub (you can do it all from VSCode, using the Source Control window (Ctrl+Shift+G)).
- Check out other recommended extensions: "Python", "Clang-Tidy", "GitLens".