Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

VSCodium

  1. Open VSCodium.

In the following sections, we will explore some useful features of VSCodium and its extensions.

Opening a project

  1. Click File > Open Folder and open your Git repository. You can trust the authors of this repository.

You should see your repository with the different labs displayed in the Explorer tab at the top of the left sidebar.

  1. If VSCodium asks whether you want to regularly perform a git fetch, you can answer yes. If you answered no, that’s fine, you will just need to remember to do it manually from time to time.

Colors

You can choose the color theme that suits you for the editor and your code by going to File > Preferences > Themes > Color Theme.

Explorer && Editor

You can create files and directories using the icons that appear when you hover over the project name at the top of the Explorer tab.

  1. Create a Lab10/ directory in your project.

  2. Create a file in this new directory with any content you like.

  3. Notice the minimap on the right side of your screen, which allows quick navigation through your code. It also displays errors and recent changes. If you don’t see it, enable it via View > Appearance > Minimap.

  4. You can also split your screen to view multiple files at once using the Split Editor Right button (a square divided into two rectangles at the top of the minimap).

  1. If you have long lines of code that do not fit on a single line, you can enable View > Word Wrap (or Alt + Z).

LSP

At the bottom of the left sidebar, you will find the Extensions tab.

  1. If you see the error Error while fetching extensions. XHR failed on Debian at the IUT, consult the VSCodium technical support to configure the proxy.

  2. Install the clangd extension from llvm-vs-code-extensions.

For clangd to work properly, it needs to know how your project is compiled. To do this, you must provide a compile_flags.txt file.

  1. Add the following compile_flags.txt file to Lab7/, at the same level as the makefile.

compile_flags.txt
-xc++
-std=c++17
-Iinclude
  1. Add the following compile_flags.txt file to Lab8/ and Lab9/, at the same level as the makefile.

compile_flags.txt
-xc++
-std=c++17
-Iinclude
-Itests/include
  1. Review the contents of previous labs (Lab7, Lab8, and Lab9). If you see errors (underlined in red), reload the clangd extension by going to Extensions > Installed > clangd, then click Disable, then Restart Extensions, and finally Enable.

Code navigation

  1. Open the file Lab8/source/fizz-buzz.cpp in the VSCodium editor.

  2. Hover over underlined headers: you should see where the corresponding header is located as well as the methods used/implemented in the .cpp.

  3. Hover over the class name FizzBuzz: you should see which header declares it as well as its documentation.

  4. Hover over the function name fizzBuzz and observe the documentation.

  1. Open Lab8/include/fizz-buzz.h, double-click on fizzBuzz, then right-click and choose Go to Definition (or press F12): you will be taken to its definition in Lab8/source/fizz-buzz.cpp.

  2. You can navigate back from fizzBuzz.cpp using Go to Declaration.

  3. Open Lab7/source/main.cpp and observe that objects and functions with parameters now display the parameter name before its value (for example title:).

This also highlights the importance of properly naming variables.

  1. Add a line in int main() starting with library. and observe the auto-completion suggestions.

  2. If you do not end the line with ;, an error will appear (underlined in red). Hover over it to see the message.

  3. If you do not save the modification, a white dot appears next to the file name. It disappears after saving (Ctrl + S).

Terminal

  1. Open an integrated terminal via Terminal > New Terminal.

You will see a panel appear at the bottom. The useful tabs for now are Terminal and Problems.

  1. If there is an error, you can view it in the Problems tab.

  2. The integrated terminal works like a standard terminal, and you can open multiple terminals simultaneously.

Search && Replace

A useful feature is searching and replacing text.

In the Search tab (magnifying glass in the sidebar), you can perform a search with replacement.

  1. Search for fizzBuzz.

  2. Click on an occurrence to view the corresponding code.

  3. Enable Match Case (Aa) to distinguish fizzBuzz from FizzBuzz.

  4. If you fill in the Replace field, you will see a preview of the changes before applying them.

Build, Run && Clean

In the IDEs you have used so far, you could compile, run, and clean your code using somewhat “mysterious” buttons.

We will now lift the curtain and build these buttons ourselves in VSCodium, which will execute the commands make, make run, and make clean.

You can of course still use these commands directly in the terminal.

In general, a project has a single root with a build file. However, since our repository contains multiple mini-projects, we will create generic tasks that can take arguments.

  1. Create the .vscode/ directory at the root of the repository (at the same level as the LabX/ directories) if it does not already exist.

  2. Add .vscode/ to your .gitignore file.

  3. Create the tasks.json file in the .vscode/ directory with the following content:

tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build",
            "type": "shell",
            "command": "make",
            "options": {
                "cwd": "${workspaceFolder}/${input:lab}"
            }
        },
        {
            "label": "Run",
            "type": "shell",
            "command": "make run",
            "options": {
                "cwd": "${workspaceFolder}/${input:lab}"
            }
        },
        {
            "label": "Clean",
            "type": "shell",
            "command": "make clean",
            "options": {
                "cwd": "${workspaceFolder}/${input:lab}"
            }
        }
    ],
    "inputs": [
        {
            "id": "lab",
            "type": "pickString",
            "description": "Select the Lab",
            "options": ["Lab7", "Lab8", "Lab9"]
        }
    ]
}
  1. Install the Task Buttons extension by spencerwmiles. This extension allows you to add buttons linked to tasks in the status bar at the bottom of the screen.

  2. Create a settings.json file in .vscode/ with the following content:

settings.json
{
    "VsCodeTaskButtons.tasks": [
        {
            "label": "🔨 Build",
            "task": "Build"
        },
        {
            "label": "▶️ Run",
            "task": "Run"
        },
        {
            "label": "🧹 Clean",
            "task": "Clean"
        }
    ]
}
  1. You should see the buttons appear at the bottom left of your screen. Click on them to test them and observe how they work.

Now that you understand what is behind the “magic” buttons in your IDEs, we will create a new “🧪 Tests” button that will execute make tests in the correct directory.

  1. Add a “Tests” task in tasks.json with the appropriate parameters and a new input labWithTests.

  2. Add an input with the identifier labWithTests and set its options to only the labs that contain tests (Lab8 and Lab9).

  3. In settings.json, add a new button with the label “🧪 Tests” in "VsCodeTaskButtons.tasks".

  4. Test your new “🧪 Tests” button.

Bonus: other useful extensions

If you are ahead, you can start the next lab on Git integration in VSCodium, as well as the basics of debugging and the use of debugging tools integrated into IDEs.