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
-
In Windows Explorer, open up your repo root folder. Click on the address bar and copy the path.
-
In the Start Menu, search for “x64 Native Tools Command Prompt for VS 2022” and run it.
-
In the command prompt, type
cd
followed by a space, and then right click to paste the path. Hit enter. -
Run the following command, replacing the
XX
with the lab number (for example02
for Lab 2 or10
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.
- Open a terminal. Install clang-format with:
brew install clang-format
Reformatting
-
In terminal,
cd
to your repo directory -
Run the following command, replacing the
XX
with the lab number (for example02
for Lab 2 or10
for Lab 10):Scripts/mac-clang-format.sh LabXX