Sdílet prostřednictvím


Hostable editor keyboard shortcuts

In my previous post about keyboard shortcuts, I promised a summary of the hostable editor shortcuts. I waited on purpose until after the RC build to make this post. There were a couple of reasons for holding off: we changed the way WF designer shortcuts were scoped, and a bunch of shortcuts were broken in beta 2 and fixed in RC. Now what you see in the RC build for keyboard shortcuts is pretty much what you get for RTM, so now I’ll get in to the nitty-gritty implementation details.

Keyboard shortcuts in the hostable editor are handled in one of two ways: using standard command routing, or using the key processor in the hostable editor. Let’s start with command routing. You may have noticed some funny looking methods on the IExpressionEditorInstance interface, namely CompleteWord, DecreaseFilterLevel, GlobalIntellisense, IncreaseFilterLevel, ParameterInfo, and QuickInfo. These methods all correspond to commands in the hostable editor. In order, they invoke automatic completion functionality, switch from Common to All tab in Intellisense list, show the Intellisense list, switch from the All to Common tab in Intellisense list, show the list of method overloads and method parameters for a given item in the Intellisense list, and show the short description of a type/method/variable/etc. The Workflow Designer receives the incoming command first, and then routes the command to the hostable editor accordingly*.

By default, the keyboard shortcuts for these commands use the pre-defined Visual Studio keyboard shortcuts (search for each individual command to see the shortcut, note that GlobalIntellisense corresponds to the ListMembers command). The shortcuts are all defined in the Workflow Designer scope (this is different from beta 2, where the commands were all in the global scope). You can remap the keyboard shortcuts for all of these commands using the Tools->Options dialog box. Make sure that if you want to use custom keyboard shortcuts in the hostable editor, you must remap the commands in the Workflow Designer scope. If you want to remap commands in the big IDE and also the hostable editor, you have to remap the commands twice – once in the Workflow Designer scope, and once in the Text Editor scope.

Say you remap a shortcut for ListMembers in the Workflow Designer from Ctrl+J to something else. Now try pressing Ctrl+J in the hostable editor. Lo and behold, the Intellisense list shows up. Why? By all command routing logic, this should not be. This is where the key processor in the hostable editor comes into play. There are a number of commands both in the default text editor (which is shared functionality between all editors in all languages, including C# and VB) and in the VB IDE that are automatically handled in those individual components. When the key processor in the hostable editor receives this key combination, the command is automatically invoked. The key processor for the text editor handles a number of common IDE commands, such as cut, copy, paste, undo, redo, select all, list members, etc. The key processor for the hostable editor IDE handles navigation key strokes (up, down, home, end, etc, including all Ctrl and Shift modifiers) and also any Intellisense commit character - "!^()=<>\:;.,+-*/{}"" '&%@?".

For the most part, you can simply ignore these technical details and go ahead and use VB IDE keyboard shortcuts and completion characters with impunity. Lots of IDE keyboard shortcuts are supported. Try them out, they’re a huge productivity boost.

* Note: dialog boxes in Visual Studio do not support command routing. This means certain keyboard shortcuts in the hostable editor are broken when you try to use them in the extended expression editor invoked by pressing the … button in the property grid.