Can't collapse pieces of code after doing Ctrl + M, P - visual-studio-2010

Ctrl + M, P expands the whole document. But after doing this I can't collapse back specific methods or pieces of code. It's not possible via shortcut keys (for example: Ctrl + M, M) neither via the menu:
As you can see, only Ctrl + M, O is possible which collapses the whole document
Also the + en - signs disappear when I do Ctrl + M, P

In VS2012 toggling outline expansion is [CTRL] + M, M. I presume this hasn't changed from previous version. Don't have VS2010 to check...

Old question, and some of this is in the comments, but I'll tie it all together in an official answer since I recently did the same thing accidentally in Visual Studio 2015 and it took me a while to figure out what I had done.
The CTRL+M, CTRL+P combination turns off outlining for the current document. It is possible to turn it back on by closing and re-opening the document as long as the "Enter outlining mode when files open" option is checked under Tools|Options|Text Editor|C#|Advanced. (there are similar options for other editor types - you can search on "outline" in the options dialog to see them all).
If you find yourself doing this often, there is a command to turn outlining back on, however, it is not assigned a keyboard shortcut by default. You can assign one though.
Open the Tools|Options|Environment|Keyboard dialog.
Enter "outli" under "Show commands containing" and look through the list below for the one named "Edit.StartAutomaticOutlining".
When you click on it, it will either show you what keys are currently assigned if a shortcut is already assigned, or will indicate nothing is assigned.
If there isn't anything listed, select "Editor" from "Use new shortcut in", then in the "Press shortcut keys" box, press the key combination you want to assign it to. For example, I used CTRL+M, CTRL+[.
Now if you accidentally hit CTRL-M, CTRL-P and turn off outlining, you can quickly re-enable outlining with CTRL-M, CTRL-[.

Related

Disable chordal hotkeys so I can use a custom hotkey

How can I disable all default shortcuts that use key chords? I am trying to add custom shortcuts, but they do not work because there are dozens of shortcuts that use the keys that I want to use as 'key chords.'
I suppose I could find which ones use my keys and go through one by one to remove them, but that would be extremely tedious, since I can only view the command that use it in the 'used by' dropdown, which only shows a few commands at once. I would have to write each of those down, search for them individually, and then remove all the shortcut assignments associated with them.
The shortcuts I intend to use are "ctrl + R" and "ctrl + T", and map them to VS's 'Comment out selected lines' and 'Uncomment out selected lines' functions.
You can go ahead and assign CtrlR to Edit.CommentSelection. Under "Use new shortcut in:", select Text Editor. Visual Studio will automatically remove all hotkey key sequences that begin with CtrlR in the Text Editor context.
I had a similar problem (at VS 2017 (Left Arrow) was pressed. Waiting for second key of chord) and found Resharper's experimental Shortcuts Live View feature invaluable in reporting what actual shortcut had been assigned and are currently active. With that you can identify where a chordal kay has been assigned, and remove it. If you're using the latest Resharper, press the left Ctrl key three times in text editor.

Visual Studio: Is there a keyboard shortcut to jump between code editor window and find results?

I can't seem to find the exact keyboard shortcut I'm looking for.
When I do a "Find in Files" (Ctrl + Shift + F), the keyboard navigation automatically jumps to the Find results, and I can navigate the results with the arrow keys; the code editor window updates itself as I do so, and pressing Enter pops me from the Find Results Window to the code editor Window.
Now, this is great for the initial search, but what if I want to bounce back and forth, say, if I need to make changes around a few different places in my find results?
Is there a keyboard shortcut to jump back from the code editor window to the find results?
I'm using MSVS 2013, if it matters.
If you have the General Development keyboard scheme, try: Alt + F6.
This is bound to the Window.NextPane which is where you just came from, so it should take you back.
Also, Alt + F7 is Window.NextToolWindowNav which pops up a nav selection which makes it easy to move around. This nav selection is the same one for Ctrl + Tab which, once open, can be navigated up, down, left and right via arrow keys.

Can I disable or change a single ReSharper shortcut?

I am using VS 2010 and there is one shortcut I really like which is a shortcut I set myself: ctrl + shift + Q in order to remove all unused usings and sort the remaining ones.
I installed ReSharper and it overwrote my VS shortcuts, so pressing ctrl + shift + Q will generate a comment (/**/).
Is there any way I can disable this single shortcut? (or change it to any other key combination that will allow me to use my old one?
I tried this solution: How to change shortcut keys for a given command in ReSharper? but my shortcut is still set in my VS configs.
Go to Tools > Options > Environment > Keyboard
Search for a command called ReSharper.ReSharper_BlockComment
Remove the current shortcut or reassign another shortcut to the ReSharper command.
I'm guessing that you've set your shortcut in Global context whereas ReSharper has assigned the shortcut to its command in the Text Editor context. The latter takes precedence when you're invoking the shortcut while editing your code.
Also, consider taking a look at ReSharper's own Code Cleanup, which takes care of unused directives, other redundant items, and formatting.
To elaborate on the steps:
Suppose you want to change the binding of "Ctrl +Q"
Open Tools Options Environment Keyboard
Under "Press Shortcut Keys" Enter : Ctrl +Q
This will show you what all commands are currently bound to this shortcut
Then search for the commands in the "Show Commands containg window " and REMOVE the assignment (for the context that you want).
Note that more than 1 command can bind to a shortcut depending on the context and so make sure you remove whatever you need
Then verify that no the binding is gone, by repeating step 2 above
Finally search for the new command that you want to bind the shortcut to and then enter shortcut and bind it in the context that you want to using ASSIGN

Keyboard shortcut for Visual Studio code editor Members and Types combos

I wonder what is the keyboard shortcut for these two combo boxs and specially the right part which list all the members of current class and is very handy for navigating a large class.
I tried to figure it out myself but I do not know the exact names to search for it.
That whole thing is called "Navigation bar" (Window.MovetoNavigationBar) and can be activated by default by pressing Ctrl + F2. There doesn't seem to be a shortcut for the right side of the navigation bar, so pressing the short cut key always takes you to the combo box on the left side. You can use Tab to jump between the combo boxes.
The keyboard shortcut is Ctrl + F2 which takes you to the left-hand combo. If you hover over each one in turn (at least in VS2k8) it shows you a tooltip which identifies the two combos as "Types" and "Members", respectively.
Pressing Tab will take you to the right-hand combo and Ctrl + ↓ will expand the combo for you.
Alternative Resharper approach #1
"Go to file member" which is "Alt+\" .
go to link for advanced features
Alternative Resharper approach #2
"Go to Next/Previous Member" with Alt+Down or Alt+Up
this one is very handy and my favorite :

Visual Studio 2010 Keyboard Shortcut Chords

I started out with VB6 default shortcuts where Ctrl + R brings up the Solution Explorer window.
Now when I hit Ctrl + R I see a status message saying that VS is waiting for me to hit the next sequence in the chord, suggesting to me that I have shortcuts that begin with Ctrl + R but require another keystroke.
This suggests to me that having one or more shortcut sequences that begin with Ctrl + Rinvalidates the Ctrl + R shortcut, which I can understand, but the question is, how do I find what those command are so I can assign a different sequence to them?
Also, shouldn't VS warn me when assigning the first chord shorcut that begins with Ctrl + R that this will invalidate my Ctrl + R shortcut or, it should clear it out so Ctrl + R is no longer a shortcut for the Solution Explorer window.
Anyway, I guess the question is how do I locate the commands that begin with Ctrl + R so I can change them so they dont collide with my Solution Explorer shortcut Ctrl + R?
In VS 2010, Tools | Options | Environment | Keyboard gets you to the right place. Now, put the cursor in Press shortcut keys, and press the keys you are interested in (so Ctrl + R). The Shortcut currently used by dropdown will then show you all the shortcuts that currently involve the keys you have pressed.
I agree it would be a 'nice to have' for VS to warn about overlapping shortcuts, but note that different shortcuts can have different scopes of effect (in the Use new shortcut in dropdown), so this might not be as easy as it sounds.
The keybindings poster from MSDN might be helpful. It looks Ctrl + R behaves differently depending on if you are debugging or not.
Have a look at IntelliCommand Plugin. This helped me out a lot in learning and remembering the chrod combinations.
Also Learn the shortcut Plugin is pretty cool too.

Resources