Skip to main content Link Search Menu Expand Document (external link)

Theme: auto

Formatting Your Code

If your code is not automatically reformatting when you save files, make sure you have done the configuration steps here. Remember that you need to do this for each lab project. When you setup the “reformat code” keep in mind you’ll need to modify the file and then save, which should reformat it.

Reformatting an Entire Lab at Once

If you have lots of source files in your lab which ended up with messed up formatting, you can also reformat them all at once.

PC

  1. In Windows Explorer, open up your repo root folder. Click on the address bar and copy the path.

  2. In the Start Menu, search for “x64 Native Tools Command Prompt for VS 2022” and run it.

  3. In the command prompt, type cd followed by a space, and then right click to paste the path. Hit enter.

  4. Run the following command, replacing the XX with the lab number (for example 02 for Lab 2 or 10 for Lab 10):

    Scripts\run-clang-format.bat LabXX
    

Mac

Prerequisites

You only need to do these steps the very first time you want to reformat a lab with the script.

  1. Open a terminal. Install clang-format with:
    brew install clang-format
    

Reformatting

  1. In terminal, cd to your repo directory

  2. Run the following command, replacing the XX with the lab number (for example 02 for Lab 2 or 10 for Lab 10):

    Scripts/mac-clang-format.sh LabXX