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

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.

Related

Visual Studio C++ Document Outline

I have CMake C++ projects in Visual Studio 2022 and would like to view the document outline for cpp/h files. But the Document Outline view is not available for this file type:
In VS Code, with the C++ extensions installed, there is a nice outline view:
But for various reasons, I need to use Visual Studio (not VS Code). I have diligently searched the extensions on Visual Studio Marketplace and found nothing that does this. It is surprising that as powerful as Visual Studio is, there is no outline view for C++ files. It seems like such an obvious feature -- I can't possibly be the only one who has ever needed it. Does anyone know of an extension for this?

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".

Visual Studio 2012 / 2013 Syntax Highlighting errors

I have a problem with syntax highlighting in visual studio 2012 and 2013 preview with C++. I've had this problem since I installed both a few days ago (tried 2013 after I saw the problem in 2012).
As you can see from below, the colours are completely messed up in the text; some keywords such as int aren't properly highlighted, the grey return value is completely broken on various texts, the class colours have merged with various texts etc.
I've done the usual stuff found from google but had zero success, such as:
Reset intellisence from %appdata%
Reset user settings via command prompt or from Tools -> Import & Export settings
Turned off hardware acceleration in Visual Studio options.
This does not happen at all in Visual Studio 2010 fortunately, so I've kept that on my machine in the mean time. I did install 2012 and 2013 while 2010 was still present on my machine, but during install, i did not select the options to import 2010 settings, so "technically" they should have been clean IDE installs. The only other thing I've noticed is; when you start a project in 2012 or 2013, all the code highlighting is completely correct, but as soon as you change or add any text, everything messes up (like in the above image). So it does seem that Intellisense or whatever controls the highlighting only functions once on start up, and suddenly stops working for the duration of the program.
Delete this key
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\FontAndColors\Cache
and restart vs2013.
Found it in a discussion on codeplex. Although my problem was the lack of colors, you should try it
I can't offer a solution to this issue, but I can tell you that it's an issue that's plagued Microsoft Visual Studio 2012. In VS2010, the highlighting was fairly basic for C++, as you couldn't set the colouring on user types and loads of other things.
In VS2010, like you I had no problem with the syntax highlighting at all, but there was a lot less that you could actually highlight. Ever since they introduced this extra highlighting for C++ so you could colour a lot more items, it's been very buggy.
At the moment, I've got operators in all sorts of colours, matching brackets and braces in different colours and half-coloured qualifiers etc. I've just had to live with it... but if you're reading this MS, please... PLEASE... pretty please get it fixed.

Visual Studio 2010/2012 Add-in Project Questions

I have already created a simple source code analyses tool for C/C++, but I wanted it to be an extension or tool for Visual Studio 2010 and 2012 editions. It is written completely in C++. For this reason I created it using "Create an Add-in using Visual C++/ATL" option. And then under "Choose Add-in Options", I have some problems. I don't know which one or ones to select. I want it to have a name and icon under Tools section, but on the other hand, my code analyzer can be used from command line too. If someone can advice me which option(s) to select there I would be glad.
My second question is this, when I have opened a source file in Visual Studio, and if I go to Tools -> MyAddin, and press it, I want it to do its job and analyze the code, and show the results in the output section below.
And my last question is that, if I have a C/C++ project with few files let's say, and if I right-click one of the files, I want to see my add-in and be able to execute the add-in from there, not to go always to Tools -> MyAddin. And also the same thing to work if I right-click the project, then it should analyze the all files and show the problems in the output section.
Please note that I have already created the source code analyzer tool in C++, and I have it as a DLL. I can also use it in Linux from terminal, and if I want I can also create a GUI for it, which I plan to do later. But I'm not that much experienced with Visual Studio, especially about add-ins, that's why I need your help. As you can see my first question is a kind of advice, but I think my second and third questions require some source code. I know that it is very hard for you to give me some help without seeing my code, but if you would help me somehow I would be glad.
For Visual Studio 2010 and 2012 you should consider using Extensions, not Add-Ins. It is a new technology introduced in Visual Studio 2010. Extensions come in form of a VSIX packages and are automatically installed in all applicable versions of Visual Studio. If you are not targeting Visual Studio version prior to 2010, I strongly recommend using extensions.
From this point of view, I will not answer any of your technical questions about Add-Ins. Here are a couple of links to start using extensions instead:
Anatomy of a VSIX Package
Building and publishing an extension for Visual Studio 2010
VSX FAQ
Walkthrough: Creating an Options Page
I think you will find valuable information on this topic here: Developing extension packages for Visual Studio 2005/2008/2010/2012 using C# with real-life samples