Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set shift + tab as keyboard shortcut in Visual Studio

I'm trying to set a Keyboard Shortcut in Visual Studio 2013 to Shift + Tab. However, when I put my cursor in the 'Press shortcut keys' textbox and attempt to press the Shift + Tab combination it doesn't put anything into the textbox and tabs back to the previous control!

Is there something that I am missing to let Visual Studio know that I am in fact entering a keyboard shortcut, and not using the command?

like image 488
Mathew Ruberg Avatar asked Nov 13 '13 14:11

Mathew Ruberg


People also ask

How do I assign keyboard shortcuts in Visual Studio?

On the menu bar, choose Tools > Options. Expand Environment, and then choose Keyboard. Optional: Filter the list of commands by entering all or part of the name of the command, without spaces, in the Show commands containing box. In the list, choose the command to which you want to assign a keyboard shortcut.

How do I run a shortcut key in Visual Studio?

In VS Code, you only need to use a shortcut to run your code. That shortcut is Ctrl + Alt + N. There are a few more ways to run code. Pressing F1 and then choosing “Run Code” also works.


2 Answers

I know the question is a little old, but I found, I think, a better answer. It is in fact possible to bind the TAB key using the Visual Studio GUI interface. The trick is to select Text Editor in the drop-down box for Use new shortcut in, like this:

enter image description here

  1. Open menu Tools > Options > Environment > Keyboard dialog.
  2. Select your desired command from the command box.
  3. In the Use new shortcut in drop-down box, select Text Editor. The default is Global, which will NOT allow you to use the TAB key.
  4. Move your cursor to the Press Shortcut Keys box.
  5. Now you can press the TAB key, or any combination, like Shift-TAB, Ctrl-TAB, etc., and it will go into the shortcut key box.
  6. Don't forget to press the Assign button! (else nothing happens)

The screen shot shows setting the TAB key to Edit.FormatSelection, so that pressing TAB correctly indents the current cursor line or block of lines (like Emacs! yay!) rather than inserting tab or space characters.

If you still want access to inserting a tab character, you can add it to another key combination, like Ctrl-TAB.

like image 97
dale Avatar answered Oct 03 '22 13:10

dale


I think that tab and shift-tab are bound to Windows, therefore even unassigning the Edit.SelectNextControl and Edit.SelectPreviousControl won't do much...

You can hack the XML though -- VS2013 saves changed keyboard shortcuts to CurrentSettings.vssettings under Documents\Visual Studio 2013\Settings

  1. Make a copy of your CurrentSettings.vssettings file in case. VS overwrites this file everytime it closes as well as when you accept.
  2. In VS, go to the keyboard shortcuts setting (Tools>Options>Environment>Keyboard)
  3. Assign the shortcut you want as Shift+Tab as Ctrl+Shift+Tab instead.
  4. Accept + Close VS.
  5. Open CurrentSettings.vssettings
  6. Do a search for the shortcut string (e.g. Edit.SelectNextControl etc.), alternatively search for Ctrl+Shift+Tab.
  7. You should have a long XML line with a part looking like Ctrl+Shift+Tab
  8. Remove the Ctrl+ so you're left with Shift+Tab
  9. Save, restart VS.

Good luck fighting Windows :)

like image 40
Slate Avatar answered Oct 03 '22 12:10

Slate