KRISCHOMAT
(Christian Grothe)
January 12, 2024, 6:58am
1
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.
retif
January 12, 2024, 8:57am
2
Sounds like a problem of Visual Studio Code, not CMake.
EDITED BY MODERATOR: Let’s keep it nice folks, I removed one remark.
ben.boeckel
(Ben Boeckel (Kitware))
January 12, 2024, 1:03pm
3
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.
Coder47
(Coder47)
October 5, 2025, 10:00pm
4
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"
}
}