Can I disable or change a single ReSharper shortcut? - visual-studio-2010

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

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.

Can't collapse pieces of code after doing Ctrl + M, P

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

How to navigate to a closing bracket with ReSharper?

Say you have a large amount of C# code in an if statement. If you place your carat next to the opening bracket, is there a hotkey or something in ReSharper that will automatically take you to the closing bracket?
VS offers this shortcut, regardless of whether you have R# installed.
Ctrl + ] will take you to the opening brace. Subsequent presses will jump between the RHS/LHS of the scope.
See Go to Matching Brace in Visual Studio? (now as an answer as requested!)
ReSharper assigns the shortcut (Control + ´ - I have german keyboard) to a different command. In order to restore it go to Tools - Options - Environment - Keyboard, search for Edit.GotoBrace and enter the desired shortcut key.
See to what command it is currently assigned and then remove it for this command first by searching this command and clicking Remove. Then again search for Edit.GotoBrace and assign the shortcut.
Directly assigning without Removing it first didn´t work.
Visual Studio's shortcut is (under the IntelliJ shortcut set): Control + ] when your cursor is on the opening brace goes to the ending brace. The inverse is also true.

Keyboard shortcut for Visual Studio/Resharper tooltips?

Is there a keyboard shortcut to display tooltips provided by Visual Studio & Resharper when you hover over a bit of code? I'm already aware of Quick Documentation (Ctrl + Q) and Quick Watch (Ctrl + Alt + Q).
Do you mean Ctrl + K, Ctrl + I? This is the command Edit.Quickinfo.
(sorry, I am unable to add a comment with the PC I have now)
For the single variable, do you mean in debug mode ?
2nd Edit: I think VS names these tooltips 'datatips'. Unfortunately, there is no command to show them, so no possible shortcut.
You can do it by binding this command to a key:
EditorContextMenus.CodeWindow.PinToSource
Unfortunately it works with what you have selected, not with what you are hovering over. Not only do you have to do the extra click, but you need to select the entire variable name and all of its prefixes as well.
Old question but useful to know.
My shortcuts:
PinToSource set to alt-F1
ClearAllDataTips set to shift-alt-F1
CTRL+ALT+Q
It is equivalent to
SHIFT+F9

How to free up a key combination in visual studio?

I want to assign a hotkey to a function, but the keys are already used in some other functions' combination.
How can I easely remove this hotkey from all these entries so I free it up and am able to asign it to the function I want?
I am using Visual Studio C# Express 2008, but you can go into Tools/Options/Environment/Keyboard. If you put your cursor in the Press shortcut keys field and type the key you want to remap, it will show you what commands use that key and let you clear or change the assignments.
Go assign the command a shortcut (Tools > Options > Environment > Keyboard). If it's already taken, that will display, but it won't keep you from assigning it to something else (which removes the shortcut from the original task).
Some key shortcuts are layered. So for instance while editing text the Text Editor keys override the Global ones. If you set your shortcut for the priority layer you can ignore whatever is assigned on a lower layer. So for text editing keys assign them under Text Editing and not Global to avoid them being ignored.
Repeat this for as many layers that you run into. I do this part incrementally only if there is some other context I want that same shortcut for.

Resources