I am working with some third-party code that has a lot of conditional macros. Visual Studio is quite good at detecting the inactive code, i.e. code wrapped in #if...#endif that won't be compiled and I can manually collapse these individually.
I would like to hide the inactive blocks automatically - all of them. Is this possible?
EDIT: is this possible with VS2012? May be a reason to upgrade.
I am not aware of a way to automatically collapse, but there is definitely a setting to hide inactive blocks.
The setting is under Tools->Options->Text Editor->C/C++->View
From there, just change "Show Inactive Blocks" to False.
Related
I usually use the CTRL+M CTRL+O to collapse sections or regions in my cs files in Visual Studio 2017. This keyboard shortcut is also working nicely in my JSX files. However, it's NOT working in JS files.
Interestingly, VS 2017 is able to see and understand functions, even sections within functions such as if blocks, etc. As you can see in image below, it also offers me those +/- icons to collapse them. Using the mouse, I can collapse them but my keyboard shortcut is not working.
How do I get VS 2017 to collapse everything to definitions in JS files using keyboard shortcuts?
The cause of this behaviour seems to be the use of the arrow-function - if you change that to a regular function-definition, the section will collapse using Ctrl+M Ctrl+O ('Collapse to definitions') like you expect it to.
This will, however, cause you to lose the perks of the arrow-function, which is less than optimal, especially when used in conjunction with promises.
What exactly is causing this, however, I haven't been able to discern, and all attempts of fixing it have so far proven futile.
Here's an example of how your outline should work as expected:
return function (dispatch) { fetch('/api/accounts/members/search', fetchOptionsPost(request))
.then(function(response) {
if(response.ok)
{
...
}
});
Can anyone confirm whether or not this behaviour occurred in VS2015?
Cheers
Edit 1: Ctrl+M Ctrl+L switches all outlines (not just definitions), which seems to include arrow-functions as well. You might have to press it twice, though, because as soon as a single item is collapsed, it expands everything.
Which begs the question whether this is not a bug, but indeed a feature, depending on whether or not you view the arrow-function as a 'definition' or not.
I have a question about Visual Studio 2013.
I just installed it and it seems pretty good because of the new features.
But there is something I do not like:
Is it possible somehow removing these 3 x buttons ? Or just one of them?
Yes you can hide them.
Close Visual Studio.
Open regedit and find MainWindowFrameControls.
For example I want to remove:
1) Sign In
2) Notifications
So I need to delete:
{304ee989-b7c9-46c8-aa48-f080bc47cee0}
{73988e61-7e30-4e87-b891-23b5e460db21}
You can also delete them and it will work (you can remove feedback also by this way).
Although sometime VS recreates that keys. But solution is very easy - instead of deleting make right click and go to Permissions, add Everyone - Deny - Read. So now nobody will be able to read that keys including VS.
You can remove it to go to original state by the same way.
At the moment the social features don't seem to have any corresponding options you can use to disable them.
There is a method that relies on using Visual Commander extension to repeatedly hide some of the buttons (as Visual Studio
often recreates them), which seems like the closest you'll get for the moment.
http://visualstudioextensions.vlasovstudio.com/2013/10/19/hide-sign-in-and-feedback-buttons-in-the-visual-studio-2013-main-window/ - You can view the code in the "Extensions" section.
Unless you're desparate to get rid of them, you're probably better of trying to ignore them, hopefully an option to hide them will become available.
You can use the Disable Social Features extension, which will programmatically hide both the 'smiley' buttons as well as your own name/photo from the front of Visual Studio.
I am wondering, if it is possible, to have some kind of automatic code-clean-up in Visual Studio 2010.
Especially interesting would be:
Auto-Indent
Remove tailing empty lines
Remove unused usings
at special cases, e. g. on save of the file.
I haven't found anything in the options, but maybe I was just kinda blinded... ...afaik in eclipse it was at least possible to intend on save. There should be something like that in Visual Studio?
UPDATE: Thanks for the fast replies, the thing is that I am ware of the keyboard-shortcuts (but nevertheless thanks for mentioning), but I am working through tons of foreign code by now and it would be awesom not having to do it manually for every file :)
Auto-indent can be done with Edit/Advanced/Format Document, or equivalent keyboard shortcut (Ctrl-K, Ctrl-D for me, YMMV).
Tailing empty lines I'm not aware of an automatic solution for, though there may be an extension available (or you could write your own).
Removing unused usings is a built in VS refactoring, and also available in tools like Resharper or DevExpress. (Right click code, then Organize Usings/Remove and sort.)
I'm not aware of a standard way to have these happen automatically for every document save, but you could probably write a macro or VS extension that would make this happen.
Some of the above already exist directly in Visual Studio:
Ctrl - K - D will reformat the document (Edit -> Advanced -> Format Document).
There is a refactoring that deals with using statements (right click in the code, there is an option for "Organise Using").
As for empty lines, I don't know of anything built in.
But tools like Resharper do have code cleanup capabilities that deal with all of the above and more (Resharper menu -> Tools -> Cleanup Code).
None of the above will execute on save by default, but you should be able to write a macro that runs on the save event.
You could try CodeMaid. Its an open source solution for what you are describing.
To Auto-indent you can ue ctrl+k+d pretty much like ctrl+shift+f in eclipse. But for unused usings I dont know any.
In VS, to use snippets (for example auto-implented property) I typed "prop", then hit TAB twice.
However R# (I'm using R#6) inserts the snippet after ONE tab, causing me to always mistype something.
Is there an option somewhere, where I can set it to use two tabs?
Unfortunately there's no way that I'm aware of that would let you reassign deployment of ReSharper live templates to two tab hits instead of a single hit.
However, until you've got used to the single-tab deployment, you can Shift+Tab to go back to the previous template hotspot, which prevents messing things up.
Another option would be to selectively turn off ReSharper live templates that conflict with Visual Studio snippets that you're used to deploy on a regular basis.
To do that, go to ReSharper > Live Templates, and in the Templates Explorer, under Live Templates, either deselect "Predefined templates" altogether or expand this category and turn off selected templates - in your example with "prop", you should turn off ReSharper's "prop" and propg (the latter is under "Imported Visual C# snippets")
Does anyone know where can I enable the bar that let me switch between different views (Design,split,..) in Visual Studio 2010 ? I can't find it and it is not enables by default
If you go into the Visual Studio Tools -> Options menu, under HTML Designer -> General there is a checkbox to enable or disable the HTML designer. Checking this and restarting VS will do the trick and show the Design/Split/Source options at the bottom again.
I really prefer the Code Optimized setup but do need on occasion to hit the design view, shame it does not seem easier to expose and, when exposed, takes up more UI than it really needs to.
Do you have the Design/source tabs down in the bottom left corner of the window? (just above where your debug & immediate windows appear from in the default view). If you do, look further to the right of them, there is a splitter bar you can drag up to produce the split mode.
It's a corrupt installation, try reintall the VS
I also cannot see the Design/Source tab split. I could have sworn it was in VS2010 RC. Did they take it out of retail?? (I'm working with an Activity xaml file)
go to Tool->Option->General->Enabe Html Designer