January 12, 2022 at 04:15 #31985
I have recently updated to Visual Studio 2022.
When using a native Win32 C++ solution formatting code with Clang works really well, even with my own .clang-format file. You can specify an own clang-format.exe (works since VS 2019), so using Clang-format version 13 is no problem.
However, VisualGDB 5.6 does not respect that setting. At least the outcome of the formatting is something very different than expected. There is the nice setting “Automatically configure clang-format from VS settings” in C/C++ (VisualGDB( but that does not seem to work. Am I missing something here. Is it possible to disable VisualGDBs formatting at all?January 12, 2022 at 16:49 #31999
VisualGDB indeed relies on a rather deep integration with clang-format in order to support various advanced features (e.g. computing smart indent for new lines based on clang-format rules). So, instead of using an external clang-format executable, our IntelliSense engine includes a copy of the clang-format logic.
We are planning to update to the latest Clang later this year, although we cannot give a specific timeframe yet, as it usually requires a lot of non-trivial changes and testing on our side.
As a workaround, you can indeed prevent VisualGDB from formatting the code automatically via Tools->Options->Text Editor->C/C++(VisualGDB)->Formatting->Automatic Formatting->Auto-format when <…> , and then launch the regular clang-format as a custom shortcut (configurable via VisualGDB Project Properties) or as a git trigger.
The “Automatically configure clang-format from VS settings” setting currently only covers the basics (tabs/spaces, simple indentation rules). Advanced formatting settings can be configured via our graphical clang-format file editor by simply opening the .clang-format file, although it will only work for settings present in clang-format 6.0.January 13, 2022 at 05:24 #32007
Yeah. As far as I have seen, the shortcuts in VisualGDB can not be triggered on something like “the currently opened/shown file”
At the moment you are overwriting two perfectly working shortcuts (CTRL-K, CTRL-D) and (CTRL-K, CTRL-F). Is there a chance to disable or reset that?January 13, 2022 at 09:44 #32025
Due to the way Visual Studio handles programming language extensions, using Clang IntelliSense automatically redirects all IntelliSense-related functionality to VisualGDB, including the formatting. There is no easy way to call the formatting logic from the regular VC++ IntelliSense while still using the Clang one.
Regarding the currently opened file, we can gladly add a new variable (e.g. $(ActiveSourcePath)) that will resolve to the currently open source file when used with custom shortcuts, if it helps you configure the formatting workaround.January 14, 2022 at 00:54 #32030
Yes, Actually I think variables like $(ActiveSourcePath) could be very beneficial for multiple scripts. Can we also apply any keyboard-shortcuts to the execution of VisualGDB custom scripts aswell?January 16, 2022 at 19:35 #32040
No problem, please try this build: VisualGDB-126.96.36.19923.msi. We have added the following variables to it:
The variables will work in the custom shortcuts and throughout the debug settings for all project types. They will also work in the build settings for the projects that are built directly by VisualGDB (e.g. Advanced CMake, Arduino, ESP-IDF).
Unfortunately Visual Studio does not allow easily assigning keyboard shortcuts to dynamically defined commands (such as VisualGDB Custom Shortcuts), however you can still launch the formatting action quickly by selecting it as an active shortcut in the VisualGDB toolbar, and then clicking the “run selected shortcut” button to the right of the shortcut combo box.January 18, 2022 at 04:46 #32045
Thanks a lot.January 19, 2022 at 04:29 #32049
It seems that $(ActiveSourcePath) does not update once it was used.
Its only working on the first file the shortcut is applied. Afterwards, when the source (or header) file is changed, the old value is still forwarded to my scripts.January 19, 2022 at 17:43 #32050
Thanks for pointing this out. Indeed, the value of ActiveSourcePath was incorrectly cached in some of the cases. We have fixed the issue in VisualGDB 5.6R3 that can be downloaded here: https://visualgdb.com/download/April 11, 2022 at 04:19 #32496
I’m adding feedback here because I also need an updated version of the clang-format engine.
You must be logged in to reply to this topic.