Unreal Engine C++ Course | ENG
  • About course
  • Links
    • Git
    • Visual Studio
    • Unreal Engine
  • Unreal Editor Hotkeys
  • Visual Studio Hotkeys
  • Console commands
  • Problems and solutions
    • Unable to start program error
  • Lessons
    • Lecture 065
      • Additive animation upon landing
      • Blocking shooting while running
    • Lecture 079
      • Pickup is visible after the ammo has been taken
      • Ammo is not picked up if character spends ammo at the pickup respawn point
    • Lecture 089
      • NiagaraSystem does not attach to muzzle
    • Lecture 148
    • Lecture 155
  • UE5
  • Automation
    • Code formatting
  • Student projects
Powered by GitBook
On this page
  • .clang-format
  • How to set an environment variable
  • Code Formatting Plugins for Visual Studio

Was this helpful?

  1. Automation

Code formatting

PreviousAutomationNextStudent projects

Last updated 3 years ago

Was this helpful?

.clang-format

For automatic formatting of project files, the file format_all_files.bat is located in the root of the repositories.

It essentially calls .clang-format on all project files:

@echo off
CD Source
FOR /R %%f IN (*.cpp, *.h, *.cs) DO (
    clang-format -i %%f
    echo %%f
)

In order for the script to work correctly, you need to add the path to clang-format to your PATH environment variable. The program is located in the Visual Studio directory. 99% that you have the same path:

c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\Llvm\bin\

How to set an environment variable

In the Windows search, enter environment and open System Properties:

Click on Environment Variables:

Select Path and click on Edit:

Insert the path to clang-format into the list, click on OK:

You can check that everything is ok on the command line using one of the commands:

clang-format -version

where clang-format

The output should be as follows:

After that, you can use the script format_all_files.bat

Code Formatting Plugins for Visual Studio

VS plugin to format all files
VS plugin for formatting when saving a file