如何:列出当前键盘快捷键映射
更新:2007 年 11 月
使用此过程可创建一个宏,该宏生成的列表列出了集成开发环境 (IDE) 中的所有命令以及根据当前键盘映射方案映射到这些命令的所有快捷键。
IDE 中提供了多种键盘映射方案。您可以在“键盘”页上更改键盘映射方案,该页位于“选项”对话框的“环境”文件夹下。有关更多信息,请参见如何:使用快捷组合键。
说明: |
---|
显示的对话框和菜单命令可能会与“帮助”中的描述不同,具体取决于您的当前设置或版本。若要更改设置,请单击“工具”菜单上的“导入和导出设置”。有关更多信息,请参见 Visual Studio 设置。 |
列出当前键盘快捷键映射
在“工具”菜单上指向“宏”,再单击“宏 IDE”。
在“项目资源管理器”中双击“MyMacros”。
右击“Module1”,再单击“重命名”。
键入 KeyboardShortcuts 作为模块的新名称。
双击“KeyboardShortcuts”可在编辑器中打开该文件。
将下面的代码粘贴到文件中 Public Module KeyboardShortcuts 之后:
Sub GetAllCommands() Dim getCommandsWithSCOnly As Boolean Dim cmd As Command Dim cmdCollection As Commands Dim ow As OutputWindow = DTE.Windows.Item(Constants.vsWindowKindOutput).Object Dim owp As OutputWindowPane Dim exists As Boolean Dim i As Integer i = 1 exists = False For Each owp In ow.OutputWindowPanes If owp.Name = "Macro Output" Then exists = True Exit For End If i = i + 1 Next If exists Then owp = ow.OutputWindowPanes.Item(i) Else owp = ow.OutputWindowPanes.Add("Macro Output") End If owp.Clear() ' Output 1 line per command For Each cmd In DTE.Commands Dim binding As Object Dim shortcuts As String shortcuts = "" For Each binding In cmd.Bindings Dim b As String Dim sArray() As String b = binding shortcuts = shortcuts + b + " " Next shortcuts = shortcuts.Trim() If Not cmd.Name.Trim().Equals("") Then owp.OutputString(cmd.Name + vbTab + shortcuts + vbCrLf) Else owp.OutputString(cmd.Guid.ToString() + ":" + cmd.ID.ToString() + vbTab + shortcuts + vbCrLf) End If Next End Sub
在“文件”菜单上,单击“保存 MyMacros”。
切换回 Visual Studio。
在“工具”菜单上指向“宏”,再单击“宏资源管理器”。
展开“MyMacros”,再展开“KeyboardShortcuts”。
右击“GetAllCommands”,再单击“运行”。
该宏生成一个列表,列出 IDE 中所有可能的命令以及这些命令在当前键盘映射方案下所具有的所有键盘快捷键映射。
在“视图”菜单上,单击“输出”。
命令及其快捷组合键将显示在“输出”窗口中。您可以复制此信息,并将其粘贴到另一个应用程序(如 Microsoft Office Excel)中,用于其他格式设置和打印选项。