Multiple keybinds to same command in Visual Studio (i.e. not vscode) - visual-studio

I am specifically using Visual Studio 2022 and would like to have two separate keyboard bindings to open the terminal (View.Terminal).

I found the answer whilst writing this, just adding new keyboard shortcuts doesn't seem to remove the previous one(s) but this wasn't obvious throught the GUI. To change keyboard shortcuts one goes to Tools>Options>Environment>Keyboard where one can see and set keyboard shortcuts. In my case it wasn't obvious because I had one keyboard shortcut per keyboard layout and the GUI only shows the keyboard shortcuts for one keyboard layout at a time.

Related

Is it possible to search for keyboard shortcuts by a keybind (Visual Studio 2017)

I want to find all shortcuts that are using a specific keybinding in an easy and reliable way.
In Visual Studio the only reliable way I've found so far is by changing a shortcut's keybinding and get list of shortcuts using the same keybinding. I think it's too roundabout and I'm looking for a way similar to VS Code.
In VS Code in the Keyboard Shortcuts tab you can search by a keybinding (by writing "Ctrl + R" for example) and you will get all shortcuts using that keybinding.
Is there a similar way to do this in Visual Studio?
If you open Visual Studio keyboard options and Press shortcut keys in the corresponding box, in the Shortcut currently used by list you will see all commands for this shortcut:

How do you switch focus directly to docked windows in visual studio?

As a vim user, I am used to being able to switch the focus to different windows that are side by side with Ctrl-W [hjkl]. While Visual Studio offers very nice organization using docked windows, I find that using the Ctrl-Tab navigation window disorienting when all I want to do is switch focus to the pane that is to the left or right of the one I'm currently using.
Is there any good way to switch focus in Visual Studio between open windows?
I am using Visual Studio 2012.
As a (Vs)Vim-mer I am also looking for that essential feature.
Yesterday my VS2013 was behaving strange, but today it is working fine again (don't know what happened), i.e.:
When you have enabled VsVim Handling for ctrl+w in
Tools/Options/VsVim/Keyboard
then Visual Studio behaves like gVim.
If it happens that Visual Studio does not behave as expected (like yesterday ;-)) then you may alternatively use the similar shortcut:
ctrl+F6 which is assigned to Window.NextDocumentWindow.
This is quite sufficient to switch between both panes. If you hold the ctrl key down and typing F6 another time then it switches to another window, so release the ctrl key when having switched the pane.
You may add / change to another shortcut for this command via the Environment/Keyboard Option.

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.

Visual Studio 2015 - CodeLens toggle on/off with keyboard shortcut

I would like to have a quick keyboard shortcut to turn on/off this feature. The feature is useful, but sometimes I want to look only at code and this feature distorts the code visual appearance.
I have bound EditorContextMenus.CodeLens.CodeLensOptions to a keyboard shortcut, but this is too slow because the Options menu takes too long to open. I would really like to have shortcut that toggles this feature on and off.
How can I do this? Did I miss some option in Environment->Keyboard or is there some add-on that can help?
To automate the Options dialog, you can create the following command in Visual Commander and assign a keyboard shortcut to it:
DTE.ExecuteCommand("EditorContextMenus.CodeLens.CodeLensOptions")
System.Windows.Forms.SendKeys.Send("{TAB} {ENTER}")
Interesting. Codelens already has some keybindings associated with it. If you press down ALT, it shows numbers over the indicators (references, source control, test), but as far as I know there isn't one to turn on/off the indicators. I'll take this feedback and file a bug for the team that owns the codelens UI at Microsoft.

I'm quite missing the Control+Tab shortcut of Visual Studio in Xcode

What is its equivalent in Xcode? Can I make my own custom shortcut in Xcode?
What other useful keyboard shortcuts in Visual Studio that has a counterpart in Xcode?
Note: Control+Tab switches code back to recently opened code
You can use this small arrow that will take you to the last edited code.
Those shortcuts are here :
Also swipe in the mouse will take you back to previous file.

Resources