Home > Software design >  How can I change the default header text of a newly created file in Visual Studio?
How can I change the default header text of a newly created file in Visual Studio?

Time:01-17

I am using Visual Studio 2022. My current project has code analyzer (with a .editorconfig file). Whenever I create a new file in this project, a header text is automatically appended to the top of the file, saying

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace MyClass
{
    ...
}

I have tried to search for a place to change this text Licensed to the .NET Foundation..., but to no avail. Does anyone know where I can update this default header text in Visual Studio 2022? Many thanks.

CodePudding user response:

You can change the text via an editorconfig rule by setting the value of file_header_template, e.g.

file_header_template = Licensed to foo bar

More details and example are available from Microsoft here: https://learn.microsoft.com/en-us/visualstudio/ide/reference/add-file-header?view=vs-2022

  • Related