How to get clang-format working in Visual Studio - c++

Visual Studio has native integration for clang-format since 15.7 prev1.
I'm using 15.9.9 and nicely see the configuration in the options.
From my understanding, as 'Google' is selected in the formatting style, it should use either my .clang-format file which is in the root of my checkout or fallback to the hard-coded configuration with name 'Google'.
However, if I format my file: Ctrl+K, Ctrl+D, my file gets formatted using Whitesmiths; which is the brace configuration of my Visual Studio formatting.
Did I forget to configure something that allows me to use clang-format or is something horribly going wrong? If it is the last one, I appreciate some debugging tips.

Strangely enough, this started to work without any extra changes after a couple of days.

Related

Visual Studio Intellisense only operates on the current Startup Project

Visual Studio Intellisense is bugging out and only works on my current startup project.
I'm in the process of building a multi-project solution and as of earlier today Visual Studio decided that Intellisense would stop colour coding and providing information about code that I hover over with my mouse.
this is happening in all files within the solution apart from the single one in my current Startup Project.
I'm unsure whether the fact that that file is inside the startup project is important or not or what at all caused the bug to begin the first place.
I've been searching around for a while and tried just about every 'solution' that has come up.
I've changed the relevant settings off and on again.
I've deleted the dynamic .suo file in the hidden .vs folder.
I've reopened the files, visual studio, updated, made sure intellisense wasn't doing something in the background.
Apparently this bug can be caused by a corrupt .ncb file that lives in the solution directories, but I've failed to locate a file with that extension anywhere.
I'm also not using any extensions or such that mess with Intellisense's operation.
Are there any other possible things to try (hopefully not reinstalling) or just continue writing code in black and white?
Intellisense working:
Intellisense not working:
Maybe you can check your intellisense setting in Tools > Options > Text Editor > C/C++:
This is a document about intellisense in C++. Hope it can help you.
If it doesn't work you can try to Reset all setting in Tools > Import and export settings. Or try to repair visual studio in visual studio installer.
If the above methods don't work, maybe you can only try to reinstalle visual studio.

How do i change the colours of visual studio? [New user]

Im currently a C++ student in uni. I started using visual studio code configurated by a friend and then i changed to visual studio 2022 (the community version).
In visual studio code the code looks prrety much like this:
Then in visual studio it looks like this:
Does anyone know how to change the highlighted or at least can give me a hint? thanks!
I tried looking in the settings on visual studio but i got confused since there are many options and i dont know exactly what to change
You are probably looking for the Visual Studio Theme Pack extension, which brings the default VS code themes to VS. Also see this blog post for other converted popular VS code themes, and this blog post which describes a tool to convert any VS code theme.
Regarding the colored (rainbow) braces, there is the "Rainbow Braces" extension (corresponding blog post).
For further configuration, you might also want to have a look at the Visfora extension, which also includes rainbow braces.
Extensions aside, many of the colors can also be manually and individually configured in the Visual Studio's options → Environment → Fonts and Colors.

How to apply format when saving in Visual Studio 2022?

I have placed a .clang-format file in my project and can apply the formatting with Ctrl+K, Ctrl+D. I have also configured and enabled "Run Code Cleanup profile on Save" under Options -> Text Editor -> Code Cleanup. But when I save a file, the formatting is not applied.
Is there something I'm missing?
Thank you in advance!
Edit: Since it does not seem to be possible for C++ (as of June 2022), I will be using the extension Format on Save for VS2022 for now, which has a bit more functionality compared to Sedenion's suggestion.
You can use the free "Format document on Save" extension (github) to format C++ code via clang-format in Visual Studio 2022 on saving.
Side note, in case anyone else is reading this: In Visual Studio 2017 and 2019 you can also use the Microsoft extension "Power Commands for Visual Studio" for this purpose.
Unfortunately, Code Cleanup only applies to C# and VB.Net, and not to C++ code.
From MS documentation
For C# code, you can also configure Visual Studio to apply these code style preferences using the Code Cleanup

Visual Studio 2017 Indent Guide Coloring

In Visual Studio 2015, I had coloring for the indent guides like this.
I can't seem to find this feature in Visual Studio 2017. Is there an extension that does this?
There's an option in the Fonts and Colors to change the color for all Guidelines. But what I want is the same in 2015 where it's automatically color coded (blue, green, teal, purple, etc.) depending on the type/level of the braces.
I think this is just what you want.This is that extension called "Indent Guides".
The number behind the '#' on behalf of the different level of the Indent Guides.
I know my answer looks terrible. Please forgive me. As a new one here, i really try my best.
Native in VS2017. It's called "Structure Guide Lines"
There is no such feature built into VS2015. It is added by extensions.
Eg. the "Structure Visualiser" from Productivity Power Tools.
However for 2017 there is a (lesser) feature built in, so the Productivity PowerTools 2017 does not include this feature. (It is now also a set of separate extentions rather than a monolithic tool.)
This is explained in a blog post see section What's Missing?
There is also an excellent extension for Visual Studio 2015 called Indent Guides that is working really well.
It is not compatible with VS2017 by default, but you can get around that by modifying the extension manifest file within the vsix file:
1) Download IndentGuide v14.vsix for VS2015
2) Use 7-zip (or other archive utility) to open the .vsix file (which is actually a .zip)
3) Edit the extension.vsixmanifest file within the .vsix file
4) Make a copy of the whole VisualStudio Version="14.0" section
5) Change that new copy to VisualStudio Version="15.0"
6) Save the manifest, save the vsix.
7) Double-click the .vsix file to install it. Ignore the compatibility warning.
This really should be a comment, but as I do not have enough reputation to make it, an "answer" it is.
A uservoice was added to solicit feedback on missing features of the current Structure Visualizer added to VS2017. If you have an interest in seeing these features restored, please vote.
Improve the Structure Visualizer in Visual Studio 2017
In the German Version of VS2017 Enterprise the setting your looking for is called "Strukturführungslinien" in Options / Environment / Fonts and Colors. I would translate it with "structurelines".

No Auto Complete Visual Studio 2010

Im using MS visual studio 2010 PRoofessional version , and in both languages I'm using (C++ and UnrealScript with Nfringe ) there seems to be no auto complete , also with the nfringe there is no auto indentation either .
I was wondering how to fix this?
Most probably you accidentally switched into low-impact IntelliSense mode by pressing
CTRL+ALT+SPACE Just hit CTRL+ALT+SPACE to go back to the IntelliSense mode.
Are you writing a totally unmanaged C++ dll? There is no intellisense support for CLI/C++ projects in VS 2010
I have actually problems with C++ and Intellisense since VC6...
We now use Whole Tomatoes "Visual Assist" and it repairs Intellisense. :-) This single feature is the money worth.
When you open the solution file, do you get a warning about being unable to open the IntelliSense database? If so, that's the reason—UnrealEngine intentionally has a directory with the same name as the IntelliSense database to prevent its creation (Visual Studio can't create a file if a directory of the same name already exists). The engine code base is so large that having IntelliSense enabled slows everything to a crawl when you're editing code.
I'm also using Unreal Engine, and I met the same problem before, the solution was set the dirs by myself in VS project setting.
Open the property window of ur game project(e.g UDKGame), navigate to "NMake", "Include Search Path", and fill the needed header search path there.
You may copy the path list from the output of UnrealBuildTool.
The values u set here is only used by Visual Studio's IntelliSense, so there's no need to worry about build error.
This only works for C++, I'm not sure what's wrong with Unreal Script. I just updated to Visual Studio 2010 and has not installed the new nFringe.
Hope this answer is not too late