Search code examples
visual-studio-2010f#hotkeysf#-interactivefsi

F# interactive - "reset session" hotkey


I have assigned a new Global hotkey to

VS 2010/Options/Environment/Keyboard/OtherContextMenus.FSIConsoleContext.ResetSession

But it seems to work only in the FSI window. How can I make the hotkey work globally?


Solution

  • I don't think you can do it the way you describe it (the hotkey will only work within the context of the FSI window), but you can use a VS Macro to change the focus to the FSI console, reset the session and move back;

    the following worked for me: (needs additional error handling etc)

    Sub ResetFSharpMacro()
        Dim WindowName As String
        WindowName = DTE.ActiveDocument.Name
        DTE.ExecuteCommand("View.F#Interactive")
        DTE.ExecuteCommand("OtherContextMenus.FSIConsoleContext.ResetSession")
        DTE.Windows.Item(WindowName).Activate()
    End Sub
    

    You can then use Macros.MyMacro.... to assign a global hotkey