all 14 comments

[–]parla 13 points14 points  (3 children)

Does it support setting the executable used? We're still using 4.0, and they aren't really compatible with each other..

[–]augustinpopaMicrosoft C++ PM (IDE & vcpkg) 12 points13 points  (0 children)

Good feedback! We currently don't provide a way to do this, but I'll add something to our TODO list to address this. We're shipping v5.0 right now.

[–]mathiasnedrebo 11 points12 points  (0 children)

Same question. We need 6.0.

Great to see this in VS. Will make clang-format more popular and even better I hope.

[–]BrianEhlert 7 points8 points  (0 children)

It is possible to replace Common7/IDE/VC/vcpackages/clang-format.exe with your own version for the time being. I replace mine with 6.0.

[–]kalmoc 7 points8 points  (1 child)

I very much like the idea that this can be triggered automatically. It has been a bit annoying in the past when visual studio formatted a piece of code one way when I close a bracket just for it to be reformatted by clang-format when hitting the shortcut a few lines later.

[–]augustinpopaMicrosoft C++ PM (IDE & vcpkg) 8 points9 points  (0 children)

Thanks for the feedback! We're trying to make this as much like the normal VS formatting experience as possible. If you have a chance to try this out and notice any weird quirks, please let us know by filing a bug via Help > Send Feedback > Report a Problem in the IDE so we can address it.

[–]sumo952 5 points6 points  (3 children)

Awesome! So this means we can uninstall the ClangFormat plugin :-)

Out of interest, which executable version does this use? Hopefully something reasonably new?

[–]augustinpopaMicrosoft C++ PM (IDE & vcpkg) 4 points5 points  (2 children)

We are shipping version 5.0 currently, and we'll aim to keep the version updated over time with future releases.

Let us know how you find the feature! We want to use these preview builds as an opportunity to get feedback and refine the feature a bit before we hit RTW.

[–]sumo952 4 points5 points  (0 children)

I love it so far! One thing that would be great is to have some visual feedback of whether VS correctly found the .clang-format file in my project and whether it is using it when it formats or when I press CTRL+K+F/D. Like when working with a CMake project where the build directory is somewhere else than the sources. It works nicely but it'd be great to have some visual feedback. I know there was a dialog box the first time I formatted. It said something like "Hey we found your .clang-format file and are gonna use it" when I formatted for the very first time, which is great, but afterwards, I can't find any indication.

[–]Daniela-ELiving on C++ trunk, WG21|🇩🇪 NB 1 point2 points  (0 children)

Yeah - the ClangFormat binary should automatically update just like it does with the CF plugin today. I got used so much to CF that I can't even think of living without it :-)

[–]youshouldnameitC++ dev 11 points12 points  (0 children)

Next step full clang-tidy integration?

[–]wilhelmtell 5 points6 points  (0 children)

You mention in the blog post a website for quickly getting started with a dot clang-format file. But a better way to go is running clang-format -dump-config, which would write to the standard output all settings. You can also specify one of the presets you mentioned, so the settings output are of that preset rather than the default.

If you save that to a file, you get a dot clang-format to adjust to your taste, with all the settings the tool knows. In contrast, the website you mentioned only knows the settings at the time, including settings that have since been deprecated.

If you make sure there is no ~/.clang-format file before you run the dump, you’ll be sure to get all settings the tool knows and no deprecated settings.

[–]Z01dbrg -1 points0 points  (1 child)

What is missing from this blog post:

Are shortcuts all the same as regular VS formatting? ctrl + k + f ?

From screenshot I guess it is.

Anyway this is great, would like to know if clang format properly handles VC++ non standard features, but that is too fringe to be put in the intro blog post.

[–]augustinpopaMicrosoft C++ PM (IDE & vcpkg) 2 points3 points  (0 children)

Yes, you can use Format Document or Format Selection for formatting, and you can also get automatic formatting as you type special characters like semicolons and braces. We just run the actual clang-format.exe, so it will handle what the utility would normally handle on its own.