Visual Studio Keymaps using PowerShell

May 16, 2010

in Uncategorized

Over on Naveen’s Blog there is a post Visual Studio Keymaps using F#.

Here are that F# code mapped to PowerShell and used in the PowerConsole.

PowerShell Code

Function Find-Command ($c) {
    $dte.Commands |
     Where {$_.name -match $c -And $_.bindings} |
     Format-Table -Autosize name,bindings
}            

Function Find-KeyMap ($key) {
    $dte.Commands |
     Where {$_.bindings -and $_.bindings -match $key} |
     Format-Table -Autosize name,bindings
}

Very Handy

PS>; Find-Command debug.bre 

 

Name                  Bindings                                                       

----                  --------                                                       

Debug.BreakAll        {Global::Ctrl+Alt+Break}                                       

Debug.Breakpoints     {Global::Ctrl+Alt+B, Global::Ctrl+D, B, Global::Ctrl+D, Ctrl+B}

Debug.BreakatFunction {Global::Ctrl+B, Global::Ctrl+D, N, Global::Ctrl+D, Ctrl+N}    

 

PS>; Find-Command exe 

 

Name                               Bindings                                       

----                               --------                                       

QueryDesigner.ExecuteSQL           {Query Designer::Ctrl+R, View Designer::Ctrl+R}

Data.Execute                       {Global::Ctrl+Alt+F5}                          

Data.SqlEditorExecuteSql           {Transact-SQL Editor::Ctrl+Shift+E}            

Data.SqlEditorCancelQueryExecution {Transact-SQL Editor::Alt+Break}               

 

PS>; Find-Command sql 

 

Name                               Bindings                                       

----                               --------                                       

QueryDesigner.SQL                  {Query Designer::Ctrl+3, View Designer::Ctrl+3}

QueryDesigner.ExecuteSQL           {Query Designer::Ctrl+R, View Designer::Ctrl+R}

Data.SqlEditorExecuteSql           {Transact-SQL Editor::Ctrl+Shift+E}            

Data.SqlEditorValidateSqlSyntax    {Transact-SQL Editor::Ctrl+F5}                 

Data.SqlEditorCancelQueryExecution {Transact-SQL Editor::Alt+Break}               

Data.SqlEditorResultsAsGrid        {Transact-SQL Editor::Ctrl+Shift+D}            

Data.SqlEditorResultsAsText        {Transact-SQL Editor::Ctrl+T}                  

Data.SqlEditorResultsAsFile        {Transact-SQL Editor::Ctrl+Shift+T}            

SqlEditorNextPane                  {Transact-SQL Editor::Ctrl+F6}                 

SqlEditorPreviousPane              {Transact-SQL Editor::Ctrl+Shift+F6}           

Data.SqlEditorToggleResultsPane    {Transact-SQL Editor::Ctrl+Shift+Alt+R}        

SqlEditorNewQuery                  {Transact-SQL Editor::Ctrl+N}      

{ 2 comments… read them below or add one }

Naveen 05.18.10 at 9:51 am

Cool one. How easy it is to subscribe to events in powershell?

Doug Finke 05.18.10 at 10:34 am

Good question. Here is one way. From the PowerConsole sample page.

PS> # Example 3: Consume DTE automation events
PS>
PS> $solutionEvents = Get-Interface $dte.Events.SolutionEvents ([EnvDTE._dispSolutionEvents_Event])
PS> $onOpen = [EnvDTE._dispSolutionEvents_OpenedEventHandler]{ Write-Host “Solution Opened!” }

PS> $solutionEvents.add_Opened($onOpen)

PS>

PS> # To unsubscribe:

PS> # $solutionEvents.remove_Opened($onOpen)

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Contrat Creative Commons

© 2007-2012, Doug Finke