Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio : How can I remap the Ctrl+E key?

I am using Visual Studio 2013, and I would like Ctrl+E to map to Edit.LineEnd. Basically, the same thing that happens when you hit end.

I can remap it under options/environment/keyboard, but the problem is visual studio still treats Ctrl+E as a chord. Instead of going to the end of the line when I hit Ctrl+E I see a message below :

(Ctrl+E) was pressed. Waiting for second key of chord.

This does not happen when I remap Ctrl+A, Ctrl+N, Ctrl+P, Ctrl+F, or Ctrl+B.

like image 788
Sperry Avatar asked May 20 '14 17:05

Sperry


1 Answers

This looks like a side effect of how Visual Studio layers command routing and key bindings...

If you look at the default bindings (my settings were based on the C# profile), you can see there are a ton of other bindings that start with Ctrl+E:

Keybindings for <kbd>Ctrl</kbd>+<kbd>E</kbd>

Important observations:

  • Each command has its context specified in parenthesis (Global, Text Editor, Workflow Designer)
  • There is already a multi-key (chord?) binding in the Text Editor
  • The Workflow Designer bindings don't matter/conflict because they're in a completely separate context

If you set your binding in the Global scope, it falls last on the priority (i.e. any specific context overrides a more generic one). Since you're in the text editor, it's trying to match the chord that exists in that context.

If you were to bind your new shortcut in the Text Editor (that's the dropdown labeled Use new shortcut in:, which defaults to Global), it would actually remove the keybinding for Edit.ToggleWordWrap. That's because you can't have a keybinding overlap with a chord, so VS assumes you really want the one you're trying to add and nukes the conflicts.

Alternatively, if you want to keep both, you could remap Edit.ToggleWordWrap to a different binding first.

like image 80
Jimmy Avatar answered Oct 13 '22 20:10

Jimmy