dev-guides

VSCode Workflow

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.

General Policy - Please Read

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.

SSH Extension

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.

Getting Started

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:

The VSCode documentation has many, many more tips.

Development Integration

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.

Formatting

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.

Miscellaneous