How does one set Visual Studio 2010 keyboard shortcuts comfortably, especially when using ReSharper? - visual-studio

In every Visual Studio.NET version you can set keyboard shortcuts using menu Tools -> Options -> Environment -> Keyboard and then find the command you want to assign a shortcut to by entering part of it in "Show commands containing".
For one thing, the listbox is ridiculously short and hard to navigate - is there an alternative?
Then, how do I find out the correct command name for a specific action?
Specifically, I'm using ReSharper 5.1 with Visual Studio 2010 and want to have the Alt + Enter shortcut back (it used to be there in older versions by default) that opens the ReSharper context menu when the cursor is over a curly underline ReSharper uses to highlight errors or warnings.
How do I find out the command name for that (except by an educated guess)?

The way I do this is to perform an action while recording a macro (using Tools / Macro / Record temporary macro).
When I have finished with the action, I look at the source code of the macro and it usually helps to find the correct command.
For example, I have just let R# add some magic through Alt-Enter, and the macro recorder has:
DTE.ExecuteCommand("ReSharper_QuickFix")

You can rebind all of the ReSharper shortcuts by using the ReSharper -> Options -> Visual Studio Integration page. Select a keyboard scheme and hit "Apply Scheme".

Related

Assigning a shortcut to Visual Assist's quick actions

In plain Visual Studio there is the Alt+Enter shortcut, which brings up a popup with quick fixes and improvement suggestions.
I am using the Visual Assist plugin for c++ development, which lets me right-click on a item and open 'Quick Actions and Refactorings (VA)' menu.
I would like to combine these two options into one: Having the advanced features in the easy accessible Alt+Enter shortcut without reaching to the mouse and right-click. Anyone knows how to assign a custom shortcut to 'Quick Actions and Refactoring'? Or any suggestions how to get rid of the tedious right-click?
Assigning shortcuts always works like this in Visual Studio:
Tools -> Options -> Environment -> Keyboard
Find the right identifier for the desired action, which is
VAssistX.RefactorContextMenu in your case.
Assign the desired shortcut Alt+Enter for the scope Text Editor and there you go.
Note, that this replaces Visual Studio's original Alt+Enter functionality, not blending them together.

Configure VS2015 Intellisense "accept" key [duplicate]

I would like Visual Studio to autocomplete the current entry in the intellisense menu only when I hit tab.
Autocompletion being triggered, for example, when I press a period, is forcing me to hit escape every time I'm writing something that cannot yet be autocompleted, to avoid that what I'm typing gets replaced with a random entry.
Is there an option to configure this?
I'm using Visual Studio 2015, and programming in C#.
Example: here I'm typing Log, which is a class for which I haven't yet added the appropriate using statement. None of the suggestions is the good one. If I hit . now, the autocomplete feature will write EventLogProcessor, which is not what I want.
Please note that this question has nothing to do with VIM, this is not a duplicate of the question linked at the top.
Use Toggle Between suggestion and Standard completion mode option of visual studio .. It will now only suggest .. and if you press Tab it will complete your choice ..
Edit -> IntelliSense -> Toggle
For Visual Studio 2012, from the Menu Bar,
Select Tools -> Options
In the left pane, expand Text Editor -> C#
Select InteliSense
The characters that commit are listed in a text box

Visual Studio 2015: Disable Control+Click Navigation

After upgrading to Visual Studio 2015, holding control while clicking on a symbol navigates to that symbol definition. In prior versions, this would instead select the entire word.
How can I disable the navigation event when CTRL + Click(ing) a symbol, so that it highlights the word?
I do have Resharper (Ultimate 9.2) installed. The configuration option under Environment -> Search & Navigation -> Go to Declaration on Control + Click in the editor is not checked.
All the search engine results make mention of this being a feature of the Productivity Power Tools extensions in previous versions of Visual Studio. I do not have that extension installed.
I found my solution in the "Options - Text Editor - General" settings. This was on VS 2017 thou.
To disable navigation to symbol definitions in VS2015,
this one worked for me.
With Resharper Ultimate 2016.3.1, I could fix the issue by disabling "Rich mouse navigation in the editor". It can be found in Resharper Options window, under Environment > Search & Navigation.
Maybe updating Resharper could solve the issue.
Also, Productivity Power Tools is not installed on my machine.
In vs 2017 this setting is available in Tools -> Options -> Text Editor -> General -> Enable mouse click to perform Go to Definition.
You can uncheck it!
Go to ReSharper Options > Environment > Search & Navigation, then uncheck the following options:
Rich mouse navigation in the editor
Enable 'Smart go to declaration'
I finally solved it following the info I found on this page..
edit
Ensure you are using Visual Studio as your resharper keyboard scheme.
Environment -> Keyboard & Menus
Tools -> Options -> Environment -> Keyboard
To stop the go to declaration, select it and input a new key short cut for it. In this image I have demonstrated that I changed this short cut to ctr num 1 and could not change it to ctr num 3. On testing crt click does not no take me to the declaration.
Find the shortcut you want to remove, in this case Edit.NavigateTo and remove.
An update for Productivity Power Tools + VS2017. Instead of having settings for this feature, a separate plugin gets installed. So after installing PPTs, you'll have a new extension called Ctrl+Click Go To Definition. Not sure why we need that tool considering it's baked into VS, but...
Anyway, Disabling that extension (plus the other things mentioned in other comments for VS and Resharper) fixed my ctrl+click woes.
To switch to the Visual C# keyboard mapping scheme
On the Tools menu, click Options.
Expand Environment, and then click Keyboard.
Select Visual C# 2005 from the Apply the following application
keyboard mapping scheme drop-down list.
or you can do
Keyboard: CTRL + W
also plugin can be used
Keyboard Shortcut Exporter
you can import/export keymapping file

Visual Studio: Shortcut to close window not working

I changed the shortcut to close a window to Ctrl+W and to close all windows to Ctrl+Shift+W. Close all windows works fine, but Ctrl+W selects the word currently under the cursor but does not close the window.
When I right-click a tab it say Ctrl+W is the shortcut to close it (And also Ctrl+S to save and Ctrl+Shift+W to close all). Why is only the close window shortcut not working?
In Visual Studio (VS 2015 in my case but it's similar down to VS 2010 at least) keyboard shortcuts may have a different meaning depending on the context in which they are executed.
Click Tools / Options / Environment / Keyboard to look up or define shortcuts (you already did that probably). What I called "context" is selected in the combobox labelled "Use new shortcut in:". Most likely you defined the shortcut in "Global" but you want it to work in "Text Editor". In the latter Ctrl+W selects the current word.
Redefine Ctrl+W for "Text Editor" and you should be fine.
I am using Visual Studio 2017 & Visual Studio 2019 and tried the answer from #TobiMcNamobi but it didn't work for me. After few such tries I got it work with below steps.
You should add it as Global shourtcut otherwise it will not work for Designer views.
Add CTRL+W as a Global shortcut for Window.CloseDocumentWindow
Remove the CTRL+W shortcut for Edit.SelectCurrentWord
In Visual Studio 2019 it is Ctrl-F4 by default to CloseDocumentWindow. The action is Window.CloseDocumentWindow. I know this is old but the accepted answer has you change the short-cut key instead. I would rather use the default option.
Tools -> Options -> Environment -> Keyboard
If you're ever unsure go to the path above and you will see the image above then you can click inside the box "Press shortcut key" at the bottom of the form and type the short cut key you're interested in and it will tell you if it is used and what it is currently used for.
You can also reference the docs
https://learn.microsoft.com/en-us/visualstudio/ide/default-keyboard-shortcuts-in-visual-studio?view=vs-2019
2021: For Visual Studio 2019:
See: https://gist.github.com/jpoehls/2030795#gistcomment-2335647
In my case, I had to existing assignments that I had to remove. Thereafter, I could use the hotkey.
In my case, the tabs were not closing because I am using Vim extension. I had to add the following lines to Vim settings:
"vim.handleKeys": {
"<C-w>": false
}
Just press Ctrl + , or Command + , for Mac users, search for Vim and go into Edit in settings.json as the following picture shows:
Screenshot
For Visual Studio 2022, make sure you also remove Ctrl+W from selectCurrentWord command.
In my VS Pro 2019, on Tools / Options / Environment / Keyboard, the first line offers using a premade keyboard mapping scheme, with a drop-down option for VSCode keyborad mapping theme.
I picked it and it seems to have adopted the keyboard shortcuts I was used to from working on VSCode, Ctrl+W included.
For those using linux with VSCode v1.56.2,
File --> Preferences --> Keyboard Shortcuts.
Search for View:Close Editor and as mentioned above, remove any keybinding that has the keybinding you want.

Adding a Visual Studio toolbar button for a command that is only available as a keyboard shortcut

This question relates to this ReSharper YouTrack issue.
In Visual Studio 2010 with ReSharper 7.1.1 installed, if I go to Tools > Options > Environment > Keyboard, there is a command called ReSharper_SilentCleanupCode.
I would like to bind this command to a toolbar button.
This seems to be impossible using Tools > Customize > Commands because the only commands available within this dialog are for actions that already have an associated menu item. The particular ReSharper command I'm interested in (Silent Code Cleanup) doesn't appear in any menu, so it cannot be assigned to a toolbar button using the "GUI".
Is there any other way to bind a keyboard-only command to a toolbar button? (One of ReSharper's programmers thought the "VS script editor" could be used, but I'm not having any luck finding info on this.)
Edit
I should have mentioned this in the first place. While azhrei's macro solution is great for Visual Studio 2010, it will break once I upgrade to VS 2012, because macros are no longer supported. If someone has a solution that will continue to work in VS 2012, that would be preferable. (Or perhaps VS 2012 toolbars don't have the same limitation in the first place?)
Add a macro that executes the command, then add the macro to a toolbar.
This works because it makes the keyboard-only command appear in the Macros menu in the Customize Commands dialog.
Details
Add a macro which does this:
Sub _ReSharper_SilentCleanupCode()
DTE.ExecuteCommand("ReSharper_SilentCleanupCode")
End Sub
Put this macro in a module which appears in Customize..Commands..AddCommand..Categories..Macros, such as Samples or MyMacros.RecordingModule, but not MyMacros.Module1 (the default when using the macro IDE).
Go to Tools..Customize..Command and select the Toolbar you want.
Now Add Command... and select the Macros category.
Select your Macros.Samples._ReSharper_SilentCleanupCode macro.
Click Modify Selection and change the name to #-) or whatever text makes you think ReSharper Silent Code Cleanup without being too long for your toolbar. :-)
I tried this with Visual Studio 2010 and ReSharper 7.1.2.
Edit
Visual Commander is a apparently way to get this going on VS2012 as well - see comments below for more.

Resources