Visual Studio 2012: Syntax Highlighting is turning off and on - c++

I'm using VS2012 and I'm quite happy with it. But the problem is, whem I'm coding in C++, that the syntax highlighting is turning off an on all over again. Sometimes, the highlighting is off and I have to reload the file. Also, it highlighting is quite slow.
Does anyone know how to fix it?

I know this is a while ago but I have had this same problem appearing randomly until just now.
It would disable when the last line in a file was a single line comment. (// blah blah). As soon as i removed that the text highlighting worked again!

Edit: In this answer I assume that your problem description is correct. In other words, I'm assuming that occasionally C++ highlighting is working, and the other times the text appears as plain text: completely black and white.
My guess is you are using an extension which modifies or replaces the way Visual Studio highlights C++ code. Try temporarily disabling all of your extensions and checking again if the editor is working. Some extensions might have the Disable button disabled; in that case you'll need to uninstall the extension for this test (possibly through Control Panel → Programs and Features).
As an example of one common extension that completely replaces the C++ highlighter is Visual Assist. However, I do not personally use that product and I haven't heard of any specific problems with it of this nature. I am merely mentioning it as an example of an extension that completely changes the behavior of Visual Studio in regards to syntax highlighting of C++ code.

For me, highlighting always stops working when the first visible line in the editor begins with the characters '//' and I trigger reparsing somehow (CTRL + S for instance).
Highlighting always works fine when the first visible line in the editor begins with anything else, even with a whitespace, and I trigger reparsing somehow.
I could indent all my comments and never experience this problem, but now that I know about it, it's not so annoying anymore, so I let it be.

This is a bug in Visual Studio 2012:
https://connect.microsoft.com/VisualStudio/feedback/details/760154/syntax-highlighting-sometimes-not-working

If you're using only Intellisense, you may go to Edit->Intellisense->Toggle Completion Mode (or hit Ctrl + Alt + Space), play with it and see if it works (maybe you've pressed this combination of keys by accident).
I've also installed Update 3 and haven't had any problems since. Who knows..

I had the same problem. Disabling the extentions sadly did not work for me.
After searching around and realizing that it only happened on larger files,
I got it to work by turning harware acceleration off.
Tools->Options...->Environment->General
*Automatically adjust [...] (off)
*Use hardware graphics acceleration (off)

In my case, it turned out that a large block of code (a 200+ line method) was commented out with // starting in the first column, and this was causing the syntax coloring not to work. I changed the commenting delineation to /* ... */ for that method and all of the syntax coloring was fixed.

Personally, I found that things like:
#if 0// bla-bla
mess up syntax highlighting badly. The solution that works for is to put a space before a comment, like so:
#if 0 // bla-bla

I installed Visual Studio 2012 Update 3 yesterday and started experiencing the exact same behavior described in the original post. Based on some suggestions in this thread, I took at look at my extensions, and disabling AllMargins fixed the issue. I've since re-enabled AllMargins and everything appears to be working as it should.
Try disabling and re-enabling any of your extensions; hopefully that will fix the issue for you.

Related

P4VS code lens integration shows all file-level changes for each function

(I've looked far and wide but I can't even find anyone having the same problem, not to mention a fix or anything. Closest is this thread which just announces the feature...)
The way it currently works for me, the VS2019 code lens integration of P4VS (for C++ at least) is almost completely pointless. Each function has an indicator added, but the information in each is identical - namely the change history of the entire file:
According to this Microsoft article, I would expect to either get function-level change information that pertains only to that function or a single change summary of the file at the bottom of the editor. But instead I get the worst combination of both.
I'm mainly surprised that I can't find anyone else talking about this, so I assume something is misconfigured on my part. Can't find anything in the configuration options though...
Is this just a bad implementation by Perforce or is something wrong on my end?
I have just found out that it can be turned off by Visual Studio options.
How to turn off CodeLens-References
Text Editor > All Languagues > CodeLens

Visual Studio 2017 (15.3.1) keeps hanging/freezing

I have recently installed Visual Studio 15.3.1 Community Edition (although I suspect this affects all editions). When doing actions such as
closing SQL .sql file tabs
copying or renaming files
other actions which I can't pinpoint
Visual Studio will freeze or hang for a few seconds or permanantly. It sometimes displays "(Not Responding)" in the title bar, but not always. This is getting really frustrating.
It seems like the Visual Studio feedback system is at fault. Turning it off solved my problem.
Open Visual Studio
Navigate to Help > Privacy > Privacy Settings
Select the "No, I would not like to participate" radio button and click OK
Hopefully whatever bug is causing this issue will be fixed soon and I'll happily participate in the feedback program again!
See this issue posted a lot on the MS forums.
I struggled with it for a while. When editing XAML files, it would always freeze and hang.
Tried many solutions that didn't fixed it. Then, I found the solution that did fix it for me.
I made two changes at the same time, so I can't say for sure which one solved it, but I can guess.
First change, which probably isn't the fix, is that I added the registry keys from this page. They were missing on my system. Page has a lot of detail, but having those keys set properly can't hurt. I noticed in Process Monitor that it was missing on the following regkey:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\Setup\CachePath
Second change I made, the one I'm guessing solved the issue, was deleting the 17k+ ".TRN" files inside the following directory:
%LocalAppData%\Microsoft\VSApplicationInsights\
On my computer they were in something like the following:
C:\Users\Michael\AppData\Local\Microsoft\VSApplicationInsights\vstelXXX_SOMEGUID
Going back to check now, and after three-or-so hours of work there's another 475 files in that folder. It's producing about four or five .TRN files a minute, all with encrypted data inside. Not going to speculate as to the purpose of it, but I doubt it's anything good or useful. Deleted all those, and the XAML editor in VS now works fine, or at least as well as it ever did. No more 30+ second hangs on a modern twentysome core workstation.
In the recent update of VS 2022, the program suddenly starts freezing (randomly) and the fix for me was to turn off inline hints (the thing that pops up when you double click Ctrl key).
I'm using VS for C++ so I turned it off for C++ specifically
Go to the Tools menu tab -> Options

How to hide and unhide a lot of comments for moment in Visual studio 2012 C++?

Sometimes I need hide a lot of comments for show code C++ in Visual studio 2012. Is it possible do it by one or two clicks?
If you have a comment block, then there should be a "-" (minus) symbol at the top left of the block which lets you collapse it:
/* <---- Collapse button to the left of this
Comment
block.
*/
If you want to do more than this (e.g. hide ALL comments), then I'm not aware of any built-in way to do this, but you may want to take a look at this add-on which claims to do just that.
According to this answer all the plug-in does is change the color of comments to be the same as your background color, so it should be easy to achieve the result manually or via your own macro / plugin (if you can't get the one on that link to work for your version of VS). This strikes me as a rather inelegant solution (you'll have what appears to be (but isn't) whitespace where the comments were, which could make it easy to accidentally erase them), but it may suit your purposes.
Near the top of the comment section there should be a minus button which will shrunk the code down to one line. Clicking the plus icon that appears will reveal the comments again.
Similarly this is available for functions or sections of code in braces.
I suffer the same issue, but in VS Code. Sorry for the unrelated answer, but I hope it provides value to someone.
VS Code has an option to fold all Block Comments. In Ubuntu, the keyboard shortcut is Ctrl + K, Ctrl + /.
http://visualstudiogallery.msdn.microsoft.com/03141ea7-c35e-4533-b05b-9e60545e93eb
this plugin seems to do a great job at comment display.

Eclipse copy code with syntax highlighting

I'm writing a document of programming guidelines for my developers team. I use MS Word. We work with Eclipse CDT (C++). I need to copy-paste C++ code with syntax highlighting from Eclipse to Word. I've tried Notepad++ and it can export text with syntax highlighting, but it's highlighting is limited to basic syntax (it doesn't know about defined class, enum etc...).
Eclipse syntax highlighting is very powerful and I wish to export directly from Eclipse to Word using it's syntax highlighting.
Is there any Eclipse plugin that achieve this purpose? Or some trick to do it (without taking a screen snapshot)?
When you copy the code to word document, you can choose the option "keep source formatting" and the highlighting will be the same as the one in eclipse.
EDIT:
As mentioned in the comments below, this won't work on folded code, so you can right click on the line numbers and select Folding > Expand All
EDIT 2:
Also mentioned in the comments, as of eclipse oxygen, the code is automatically copied with syntax highlighting
When I copy from Eclipse straight to PowerPoint some of the formatting is messed up. Bold and color seems to "keep going". But if I copy from Eclipse to Word -- and then from Word to PowerPoint (with the keep source formatting CNTRL-K) -- the formatting is correct. I recently upgraded Eclipse to Mars and Office to 2013. I still have to go through Word first.
I was trying it too and for some reason not every compile unit would keep the formating.
After a while I've seen that you also won't get the formating kept if there are parts of the code hidden, so for the ones that cannot make it work with the answers above, just make sure that there are no "+" signs on the left of your code (mine were where the imports at the beggining).
Copying of formatting is supported since version 3.2
Note that everything is copied: highlighting of spelling errors, marked variables/types/etc and underscoring of warnings/errors.
To avoid that, turn off spell checking, "Mark Occurrences" and "Report problems as you type" respectively.

Are there any Visual Studio add-ins for true 'smart tabs'?

'Smart Tabs' concept allows to automatically insert tab character for block indentation and space characters for in-block formatting. It's described here. Unfortunately, Visual Studio's 'smart tabs' option in text editor settings just indents text on enter press. Same name, completely different and near useless thing :). So, maybe someone knows of a visual studio addin that can change how 'tab' key work so it will insert tab characters and space characters according to rules mentioned above? Any hints are welcome.
Update: I need it for C++. According to comments, ReSharper can do something like this, but only for Basic and C#.
I have mapped the tab-button to Edit.FormatSelection in Visual Studio to achieve this and it works very well for me. I have also remapped the normal functionality of tab so that I still can access them (Edit.InsertTab and Edit.TabLeft).
If no one comes up with an "as-you-type" utility, then Astyle with its convert-tabs and indent=tab options will reformat code after-the-fact.
ReSharper does this pretty well, and is highly configurable.
Have you looked at Visual Assist?
It's been a while since I used it (back on VC++ 6.0!), and I can't see a mention of "Smart Tabs" on the home page, but it might be there somewhere.