如何对Visual Studio Extension执行快捷键命令

时间:2017-04-26 15:01:50

标签: visual-studio-2015 vs-extensibility

我正在开发一个Visual Studio扩展,它需要使用快捷键Ctrl + 6执行命令,用户应该能够像VS build命令一样执行命令(Ctrl + F5)。我使用了以下方法,但是在选择文本编辑器时需要执行命令。请告知如何解决此问题。

<KeyBindings>    
    <KeyBinding guid="CommandSet" id="MyCommand" key1="6" mod1="CONTROL" editor="guidSourceCodeTextEditor" />
  </KeyBindings>

  <Symbols>
    <!-- This is the package guid. -->
    <GuidSymbol name="MyPackage" value="{ccccc-cc-cc-cc-ccccc}" />
    <GuidSymbol name ="guidSourceCodeTextEditor" value="{8b382828-6202-11d1-8870-0000f87579d2}" />

    <!-- This is the guid used to group the menu commands together -->
    <GuidSymbol name="CommandSet" value="{xxxxx-xxxx-xxx-xxx-xxxxxxx}">
      <IDSymbol name="MyCommand" value="0x0100" />      
    </GuidSymbol>        
  </Symbols>

1 个答案:

答案 0 :(得分:1)

问题在于:

editor="guidSourceCodeTextEditor"

我认为您需要将其更改为:

editor="guidVSStd97"

请参阅https://msdn.microsoft.com/en-us/library/bb491775.aspx