How to disable the "go to definition" on pressing CTRL key in Visual Studio? - visual-studio

I usually use the CTRL+click combination to select one word, but in Visual Studio 2017 (15.4) when I press CTRL the word is turned into a hyperlink that goes to its definition, I want to disable it:

Tools->Options->Text Editor->General
Uncheck Enable mouse click to perform Go to definition
It will work

This setting has no effect when the "Ctrl+Click Go To Definition" Extension from Microsoft Marketplace is installed. The setting specified on the extension documentation page wasn't visible in the Options, Productivity Power Tools, Other Extensions, and hence, masked the real problem. Uninstalling the extension allows reverting to classic Ctrl+Click select behavior.

Related

In Visual Studio, what is the keyboard shortcut and Command ID to "search/query everything box"

In Visual Studio 2021 or above what is the keyboard shortcut (KeyMap) Command ID to the "search everything box"? This box is displayed top right of IDE menu bar. It offers a global search including, IDE actions, menus, commands and symbols within code.
The default Ctrl+Q is NOT assigned on my config, used for something else.
Please see the screenshot:
Could not find the correct command in KeyMap. For information, in JetBrains Rider, this command is called "Search Everywhere".
On my installation of VS 2022 the placeholder text within the search box is "Search (Ctrl+Q)".
Pressing this shortcut in the keyboard mappings yields the Shortcut Window.QuickLaunch
The page you linked to also shows this is the default settings for Window.QuickLaunch.
According to Visual Studio documentation
Use the Ctrl+Q keyboard shortcut to access the search box
Advance Shortcuts:
The search results include tabs for All, Code, Visual Studio. You can save time by using the following keyboard shortcuts for different types of searches:
Ctrl+Q, Ctrl+T for files, types, and members
Ctrl+Q, Ctrl+M for Visual Studio menus, options, components, and templates
Ctrl+Q, Ctrl+E to go to the All tab, for both
Please try with Ctrl+Q it is working fine in visual studio 2022.

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.

How to remove all resharper keybindings?

I like resharper fine, but with the new pricing, the trial ran out and I want to try life without it.
Except after disabling all the Resharper commands are still bound in my keyboard options! So ctrl+, doesn't fall back to the standard VS behavior because its bound to Resharper.Resharper_GotoRecentEdits which is, of course, disabled.
Even clicking Reset in the keyboard options does not remove the keybindings.
So what the heck. How do I get rid of all the resharper stuff? It is currently suspended and doesn't have a menu item.
This is Visual Studio 2015 with Resharper Ultimate trial
The following steps worked for me:
Disable ReSharper
In ReSharper's options -> Keyboard & Menus, select the Visual Studio scheme and click on Apply Scheme.
Mind the note under the Apply Scheme button: Click save to close the ReSharper Dialog and...
In TOOLS --> Options | Keyboard, make sure the right mapping scheme is selected (Visual C# 2005 for me) and click Reset and finally, Ok
That did the trick for me. opening the keyboard dialog once again and hitting Ctrl+, in the Press shortcut keys was no longer showing the key mapping to be bound to Resharper.Resharper_GotoRecentEdits
As per my comment on the initial post - it seems sometimes you have to uninstall ReSharper to remove the key bindings.

Can you turn off Peek Definition in Visual Studio 2013 and up?

In Visual Studio 2013 and up, there is the Peek Definition feature when you Ctrl + Click. At first I thought this was cool, but I have found that the majority of the time, I need to click the Promote to Document button, since I make lots of changes to the files I Ctrl + Click on. But after Googling how to turn off Peek Definition, I can't find any details on if this is possible. What I would really like is for the Ctrl + Click functionality to go back to opening the definition in its own tab, like in previous versions of VS. Is this possible?
In pre 2017 Visual Studio:
Tools→Options→Productivity Power Tools→Other Extensions→Control click shows definitions in Peek
Adam Garner pointed out that in Visual Studio 2017, the location is:
Tools→Options→Text Editor→General→Enable mouse click to perform Go to Definition
If you have Resharper AND Productivity Power Tools, by default this will cause ctrl + click to go to definition AND peek the definition. Very annoying. The solution from #SnowFatal will turn off the peek functionality. Resharper's option is listed as "Go to Declaration on <Control + Left Click> in the editor".
In the latest version of Visual Studio 2017 (15.4.0) it is:
Tools→Options→Text Editor→General→Enable mouse click to perform Go to Definition
You can either disable it by unchecking the box, or set a different key to trigger the mode.
Ctrl + Click -> Peek Definition is actually enabled by Productivity Power Tools. If you disable "Ctrl + Click Go To Definition" in Productivity Power Tools options then this behaviour will disappear.
For Visual Studio 2017 it is:
Tools→Options→Productivity Power Tools→General→Control click shows definitions in Peek

Resources