Format the generated .h and .cpp files

Hey There

I was wondering if there was a way to set up the formatting of the generated .h and .cpp files when creating a new c++ class in unreal.

What i mean is this is the generated .h file when creating a new class

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"

UCLASS()
class BUILDINGESCAPE_API AMyActor : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AMyActor();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

};

and this is what i would like to it to get set as

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"

UCLASS()
class BUILDINGESCAPE_API AMyActor : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AMyActor();

	/*** Functions ***/
private:
protected:
	
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	/*** Variables ***/
private:
protected:
public:

};

Is there a way to tell unreal this? so that when i create a new class it formats automatically as above??

Not without modifying the engine code that’s responsible for that as far as I know.

Firstly Thanks for the reply.

Secondly would you know where in the engine code i could do that or where i can go to get started in finding it?
I am not afraid to rebuild the engine code as i have done it before.
And i think being able to format the generated files could really help speed things up, so that we dont have to continually update the format when ever we create new file.

Again Thank you for your time on this

Probably somewhere in Engine/Source/Editor/GameProjectGeneration. Alternatively you could just create a script that reorganises the file.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.