If you’re a fan of Visual Studio Code (VSCode), you can work on SPOC directly from a VSCode window on your local computer using SSH, allowing you to take advantage of all of VSCode’s features in a local-quality development experience.
In general, VSCode is a significantly more resource-intensive application than other editors such as Vim. Out of respect to the other students in this course, please do not install extensions outside of the few described in this guide when using VSCode on SPOC, as this can limit the resources (particularly memory) available to other students.
Please also remember your pledge. Extensions such as Github
Copilot
and Github Copilot Chat
are strictly prohibited from this course.
Once you’ve installed VSCode on your local machine, all you have to do is install the VSCode SSH Extension.
From now on, you can SSH into SPOC by opening your Command Palette
(Ctrl-Shift-P) and looking for Remote-SSH: Connect to Host
.
Alternatively, you can click the double triangle icon at the bottom left corner
of the window. This will give you a variety of SSH-related options. Selecting
Connect to Host
or Connect Current Window to Host
will give you a list of
remote machines from your SSH config file. Choose your shortcut for SPOC - if
you’ve properly configured your SSH keys, it should log in automatically and
start setting up a remote VSCode server.
See the SSH extension documentation for more features and tricks.
When you open VSCode, the Welcome screen will recommend a few tutorials. We highly recommend going through these - they cover several essential VSCode features and various tips and tricks.
As a bare minimum, you should know the following:
After opening a remote folder, use Ctrl-P to quickly open any file in your workspace.
Use Ctrl-J to open an integrated terminal to run commands on SPOC. You can use the same shortcut to hide the terminal.
Whenever you open a new VSCode window, the Welcome Tab has a “Recent” section that allows you to quickly open files from past sessions.
The VSCode documentation has many, many more tips.
First, you should install the C/C++
Extension. This will enable several useful
features for C development.
VSCode will parse all of the files in your workspace to enable advanced functionalities like semantic auto-complete and quick jumping to variable definitions and references.
VSCode may also assume that the .c
and .h
files that you use are C++ files,
rather than C files. You can change this on the bottom right as well, along with
changing the default file association behavior.
For readability and to facilitate collaboration, we recommend you use a code
formatter. VSCode’s C/C++
Extension allows you to format your code quickly
using Alt-Shift-F.
By default, VSCode will search for a .clang-format
file for determining the
style to format your code. You can also choose to set a default formatting style
such as LLVM
or Google
by configuring the C_Cpp: Clang_format_style
configuration. You can also configure VSCode to format on save.
The LiveShare
extension can be useful for partner programming on the working
directory. See VSCode’s LiveShare guide for more information.
The GitLens
extension can be very helpful for managing branches and remotes
within VSCode.
One of the benefits of VSCode is that in addition to being highly
configurable, it’s very visually appealing. You can change the default theme
to one of VSCode’s built-in themes by going to the Command Palette and
searching for Preferences: Color Themes
. Use your arrow keys to switch
themes and preview the selected theme. Once you’ve settled on a theme, click
on it to select it.
You can also install additional themes using VSCode’s Extensions
functionality. Go to the Extensions tab (the four squares on the left
sidebar), and search for @category:"themes"
. This will give you both color
themes and file icon themes, which can be set in Preferences as well.
You can also customize existing color themes or create your own, if you’re so inclined. See the documentation for more information.
You can add rulers in VSCode marking various columns. This makes keeping track
of line length much easier. We recommend adding rulers at columns 80 and 100,
the traditional Linux max line length and the new max line length. To do so,
insert the following in your VSCode settings.json
:
"editor.rulers": [
80, 100
]