Shortcut for making UE_LOG statements in Visual Studio

I made a custom code snippet for Microsoft Visual Studio 2022 (not Visual Studio Code). I just type uelg [TAB] and UE_LOG(LogTemp, Log, TEXT("")); gets inserted into my editor, with the cursor located between the quote marks.

Here’s what I did (using these instructions as a guide)

Step 1
Create a file called unreal-log.snippet that has this in it:

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>Unreal log statement</Title>
            <Description>Inserts unreal log statement</Description>
            <Shortcut>uelg</Shortcut>
        </Header>
        <Snippet>
            <Code Language="CPP">
                <![CDATA[UE_LOG(LogTemp, Log, TEXT("$LogText$"));]]>
            </Code>
            <Declarations>
                <Literal>
                    <ID>LogText</ID>
                    <Default></Default>
                </Literal>
            </Declarations>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

Put the file in C:\Users\USERNAME\Documents\Visual Studio 2022\Code Snippets\Visual C++\My Code Snippets\

Step 2

  • Restart Visual Studio
  • Go to Tools > Code Snippets Manager
  • Choose Visual C++ as the language
  • Expand “My Code Snippets”
  • Confirm you see “Unreal log statement” under that folder
  • Click OK

You may need to repeat step 2 for each new project.

8 Likes

Thanks man :wink:

Visual Studio now has its own built-in snippet called uelog:

Thought I’d mention for everyone’s benefit :slight_smile:

1 Like

Thanks for this! Simply typing “uelog” does the trick :slight_smile:

1 Like