Search code examples
visual-studioeditorconfig

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


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.


Solution

  • 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