VSCode formatting issue on .h.in file

I just started the cmake tutorial and ran into an issue. When I want to set the .h.in file to

#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@

and then save the file, vscode create a space before the last @ character like:

#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR @
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR @

I dont know where I can change this behaviour. I disabled prettier but the issue stays the same.

Sounds like a problem of Visual Studio Code, not CMake.

EDITED BY MODERATOR: Let’s keep it nice folks, I removed one remark.

Potential solution? In Files - Visual Studio Marketplace

Maybe a configuration change? visual studio code - VSCODE inserting spaces via format on save - Stack Overflow

But yes, not a CMake problem. I suggest asking a VSCode user forum.

Just hit this. I realize this is not a cmake issue but in case others like me land here, this is what worked for me. .h.in files get associated with cpp formatters. In this case you want to associate them with cmake and then use the cmake formatter. So add this to your vscode Workspace settings. (or User if you want it like this everywhere):

{
    "files.associations": {
        "*.h.in": "cmake"
    },
    "[cmake]": {
        "editor.defaultFormatter": "ms-vscode.cmake-tools"
    }
}