Is there a way to highlight a piece of code in Visual Studio C# and automatically place a pair of parentheses around the block of code rather than manually put your cursor at the beginning and press '(' and then the end and press ')'?
I've used other IDEs that have had this feature and as simple as it sounds, it's very nice to have.
I'm currently working with Visual Studio 2017.
To my knowledge, Visual Studio doesn't provide that functionality out of the box. However, there are free extensions you can download from the Visual Studio Marketplace that do what you describe such as:
Surround Selection
Selection Wrapper
You can download them from the marketplace using the links above or by searching in visual studio (Menu: Extensions -> Manage Extensions -> perform your search)
Disclaimer I’ve only tried out the first one of these briefly and it appears to work. I will update after checking the second one.
Edit: I've now tried both and both worked. Please note that I use VS2019 so I can't vouch for their performance on VS2017. Of the two options I mentioned, Surround Selection claims to work with VS2017 while the second one only lists VS2019.
Related
I have a page open writing some code and then out of nowhere after some random time my page reformats and my spaces get turned into tabs. I have to close the file and re-open in order for it to get fixed. Please have a look at the screenshot below.
I am using c# and Visual Studio 2019. I Recently updated to the latest version of visual studio and this is when this started happening. I am now on version 16.11.4. I also installed .NET 5 at the same time so not sure if something there could be messing with visual studio.
Edit: I Think I figured out why the spaces are added. If you look at this new screenshot you will see that it injected the gray lettering where spaces were. I tried clicking around in the empty spaces few times and those gray letters showed up. I Guess the page is having trouble loading all these in until I click on them?
Anyone has any idea why?
I had the same problem when I had Resharper installed, and I upgraded to the latest version of Visual Studio.
Are you using Resharper? If yes, disable it or downgrade Visual Studio to a version compatible with your version of Resharper.
I believe this is caused by your word wrapping preferences and then resizing your window. Go to File - Preferences - Settings and then search for "wrap" and play around with the settings or turn it off.
I'm working on a Visual Studio solution using Visual Studio Professional 2017, the solution consists of four types of projects:
Several C++ projects
A C# project
Several C++ unit test projects
A C# unit test project
IntelliSense seems to be working for all, except for (at least) one of the C++ unit test projects, and it goes even further: for some tests inside that particular C++ unit test project, IntelliSense is working, but for some other, it isn't.
As mentioned in other Stackoverflow posts, I've already removed the *.cache files and there are no *.ncb files (so I can't remove them :-) ).
I also consulted the MSDN website, as proposed by Visual Studio:
Intellisense: 'No additional information available' (See 'Troubleshooting Intellisense in C++ Projects' for further help.)
I typed the mentioned sentence in MSDN search (learn.microsoft.com), and I got 229 results, which looked useless, and I got 0 results while searching for the exact phrase. :-(
Another approach : in my Visual Studio settings, I've maximised the messages, sent to the output window, I've rebuilt the whole solution, and afterwards I looked for the word IntelliSense in the output window. There was nothing. Then I typed something in order to launch IntelliSense, I verified the output window, but nothing was added.
In order to solve this problem, I need detailed information about IntelliSense itself:
I believe that IntelliSense is based on some files. Which ones?
I also believe that IntelliSense is keeping its own information in memory. Is this correct, is there a way to store this memory mapped information in files? If yes, which ones, and how can I force IntelliSense to refresh its information?
Whatever IntelliSense is doing (filling its information in memory, saving it in files, retrieving its information from those files, ...), what can I do in order to log those actions, so that I have an idea what might be going wrong?
In other words, does anybody have background information on the IntelliSense background task, which might explain what's going wrong, and how I can derive (from information in output window or other) what to do?
Thanks in advance
You can try resetting Visual Studio once
Devenv /ResetSettings
Sometimes Visual Studio has these gnawing bugs that just stresses you out for no reason.
Remove the hidden .vs folder from your solution. That would trigger index rebuilding.
Also you can try to install recent update for Visual Studio 2017, they seem to work actively on improving the indexing.
After updating to visual studio 2013, update 4, the TEST option is missing from my screen, I thought Visual Studio update 5 would fix it, but it did not. "TEST" is missing from my options and I don't know why.
I have tried resetting the settings, it does not help, reset settings:
I cannot add test via TOOLS -> CUSTOMIZE -> COMMANDS -> ADD COMMAND, it is not there.
What edition of Visual Studio are you working with? Have you ever had
the TEST menu present?
Yes, I've run tests before, I'm currently
at Visual Studio 2013.5 - Premium flavor
#OP answered:
I don't know why, but uninstalling Office Tools extension seems to have fixed it.
I wanted to provide an explanation for why Menu's can go missing. One reason for this is when you install another component for Visual Studio, like Team Foundation Client or in this case Office Tools extension. They "may" automatically select a different setting. To check if this is the problem:
In Visual Studio click Tools Menu > Import and Export Settings:
See here how Project Management Settings is selected, that is the wrong setting if you're a Developer.
To see the missing developer menu's reset it back to a developer setting.
Ref: http://blog.accentient.com/a-visual-studio-mystery-the-case-of-the-missing-menu-items/
I had the same issue in VS 2015 Update 2 Community and the culprit apparently was AppInsights extension (https://github.com/dotnet/roslyn/issues/11653). To provide some detail:
Noticed test menu missing in existing solution where I previously ran tests
Made a blank test project, still no test menu
closed vs and reopened. Still not test menu
Got error referencing C:\Users{username}\AppData\Roaming\Microsoft\VisualStudio\14.0\ActivityLog.xml
Last error in there was NullReferenceException in CodeLensIndicatorService
Googling that found link above, tieing to this add-in.
disabling it fixed the issue and test menu not appears and I can run tests.
Forgive me if I complain a bit, but if any VS team is reading: Under no circumstances should an add-in failing cause a built-in menu to not appear. As much as this is a bug caused by the the various add-ins, it is also a flaw in VS IMO- and one that is not trivial for end-users to connect the dots on.
Somehow the settings (settings have menu items configuration also) for your visual studio may have issue. Either you can try reset. Only in case that doesn't work you can always customize your menu item. so
Tool -> Customize (by default standard should be selected)
select commands tab and then menu bar option. You can see options to add commands. Under that you can select test so make testing option visible.
Also for testing test case, you can always right click on class and run it.
Hi Please try to reset all setting
http://blog.accentient.com/a-visual-studio-mystery-the-case-of-the-missing-menu-items/
If not then there is workaround to add your setting
http://blogs.msdn.com/b/visualstudioalm/archive/2012/09/11/visual-studio-2012-where-is-the-test-toolbar-couldn-t-find-it-anywhere.aspx
After doing close visual studio instances and reopen it.
I don't know why, but uninstalling Office Tools extension seems to have fixed it.
Edit: I tried to reproduce this bug, I ran the VS2013.5 update and clicked repair. The update took +5 hours, figured it got stuck. So I cancelled it, got stuck cancelling. So I ended the process. Now I started visual studio and TEST is missing, basically my visual studio installation is messed up I think.
Edit: Found the culprit, it was Microsoft Intune Endpoint Protection that was installed on my pc. It basically scanned everything and when visual studio got updated and files were written to the disk, something went wrong and corrupted my install. I turned it off by excluding C:\* from being scanned and ran VS2013.5 update and clicked repair. Everything is fine now.
I am looking for a plugin for VS 2012 that would show me which lines of code have been modified or created since the last build. Anyone know of something for this?
You could use a Visual Studio SVN plugin to view changes visually within Visual Studio.
EDIT: as mentioned in my comment below, the next closest thing to what you seek is change tracking. As you bring up in your comment it will only work for your purposes if the only time you save is when you build. I tend to save as often as possible though.
And yes, the default behavior of VS is to automatically save when you build.
I was using Visual Studio 2010 Express for a project and recently changed over to ultimate 2010. I am noticing that when I would debug in express I could put a break point, edit the code if needed and continue without having to recompile.
With VS 2010 ultimate it tells me the version has changed and i have to stop and restart. How do i get the functionality that express had in ultimate?
Thanks for the help.
EDIT: More specifically, here is the message i get:
"This source file has changed. It no longer matches the versio nof the file used to build the application being debugged".
You have to enable 'Edit & Continue' both in the debug menu (should be on by default. check by going to debug > options+settings) and possibly again in the specific project if it's a web project of some sort. It should be a checkbox there.
edit: it's been a bit since i've tried it, but as far as i recall, that's the how. i'll see if i can grab you a link.