Tuesday, July 01, 2014

PowerShell ISE Keyboard Shortcuts

I hit a recent issue using the ISE and trying to use the updated version of James Brundage’s ISEPackv2 module – a keyboard shortcut used in James’s module has been taken by a later version of PowerShell. Not the end of the world and easily remedied (heck, I have the code!). I was playing around with keyboard shortcuts and wrote a little function that, when run inside the ISE, gets the keyboard shortcuts that are set.
I’ve published the Get-ISEShortcut over on my PowerShell scripts blog, but the core of function is these lines of code:
$gps = $psISE.GetType().Assembly
$rm = New-Object System.Resources.ResourceManager GuiStrings,$gps
$rm.GetResourceSet((Get-Culture),$True,$True) |
    Where Value -CMatch "(F\d)|(Shift\+)|(Alt\+)|(Ctrl\+)"
This code gets the GUI related resource strings held by the ISE and then weeds out all but he keyboard shortcuts. In the published script, I sort them to get a more effective list. On my system, I get the following:
PSH [C:\foo]: Get-ISEShortcut | ft -AutoSize value, name
Value               Name                                          
-----               ----                                          
Alt+Backspace       EditorUndoShortcut2                           
Alt+Down            EditorSelectNextSiblingShortcut               
Alt+F4              ExitShortcut                                  
Alt+Left            EditorSelectEnclosingShortcut                 
Alt+Right           EditorSelectFirstChildShortcut                
Alt+Shift+Backspace EditorRedoShortcut2                           
Alt+Shift+Down      EditorBoxSelectLineDownShortcut               
Alt+Shift+H         ToggleHorizontalAddOnPaneShortcut             
Alt+Shift+Left      EditorBoxSelectToPreviousCharacterShortcut    
Alt+Shift+Right     EditorBoxSelectToNextCharacterShortcut        
Alt+Shift+T         EditorTransposeLineShortcut                   
Alt+Shift+Up        EditorBoxSelectLineUpShortcut                 
Alt+Shift+V         ToggleVerticalAddOnPaneShortcut               
Alt+Up              EditorSelectPreviousSiblingShortcut           
Ctrl+1              ShowScriptPaneTopShortcut                     
Ctrl+2              ShowScriptPaneRightShortcut                   
Ctrl+3              ShowScriptPaneMaximizedShortcut               
Ctrl+A              EditorSelectAllShortcut                       
Ctrl+Add            ZoomIn1Shortcut                               
Ctrl+Alt+End        EditorMoveCurrentLineToBottomShortcut         
Ctrl+Alt+Home       EditorMoveCurrentLineToTopShortcut            
Ctrl+B              BreakAllDebuggerShortcut                      
Ctrl+Backspace      EditorDeleteWordToLeftShortcut                
Ctrl+Break          StopExecutionShortcut                         
Ctrl+C              StopAndCopyShortcut                           
Ctrl+D              GoToConsoleShortcut                           
Ctrl+Del            EditorDeleteWordToRightShortcut               
Ctrl+Down           EditorScrollDownAndMoveCaretIfNecessaryShortcut
Ctrl+End            EditorMoveToEndOfDocumentShortcut             
Ctrl+F              FindShortcut                                  
Ctrl+F1             ShowCommandShortcut                           
Ctrl+F4             CloseScriptShortcut                           
Ctrl+G              GoToLineShortcut                              
Ctrl+H              ReplaceShortcut                               
Ctrl+Home           EditorMoveToStartOfDocumentShortcut           
Ctrl+I              GoToEditorShortcut                            
Ctrl+Ins            Copy2Shortcut                                 
Ctrl+J              ShowSnippetShortcut                           
Ctrl+Left           EditorMoveToPreviousWordShortcut              
Ctrl+M              ToggleOutliningExpansionShortcut              
Ctrl+Minus          ZoomOut3Shortcut                              
Ctrl+N              NewScriptShortcut                             
Ctrl+O              OpenScriptShortcut                            
Ctrl+Oem6           GoToMatchShortcut                             
Ctrl+Plus           ZoomIn3Shortcut                               
Ctrl+R              ToggleScriptPaneShortcut                      
Ctrl+Right          EditorMoveToNextWordShortcut                  
Ctrl+S              SaveScriptShortcut                            
Ctrl+Shift+Add      ZoomIn2Shortcut                               
Ctrl+Shift+D        GetCallStackShortcut                          
Ctrl+Shift+End      EditorSelectToEndOfDocumentShortcut           
Ctrl+Shift+F9       RemoveAllBreakpointsShortcut                  
Ctrl+Shift+H        HideHorizontalAddOnToolShortcut               
Ctrl+Shift+Home     EditorSelectToStartOfDocumentShortcut         
Ctrl+Shift+L        ListBreakpointsShortcut                       
Ctrl+Shift+Left     EditorSelectToPreviousWordShortcut            
Ctrl+Shift+Minus    ZoomOut4Shortcut                              
Ctrl+Shift+P        StartPowerShellShortcut                       
Ctrl+Shift+Plus     ZoomIn4Shortcut                               
Ctrl+Shift+R        NewRemotePowerShellTabShortcut                
Ctrl+Shift+Right    EditorSelectToNextWordShortcut                
Ctrl+Shift+Subtract ZoomOut2Shortcut                              
Ctrl+Shift+U        EditorMakeUppercaseShortcut                   
Ctrl+Shift+V        HideVerticalAddOnToolShortcut                 
Ctrl+Space          IntellisenseShortcut                          
Ctrl+Subtract       ZoomOut1Shortcut                              
Ctrl+T              NewRunspaceShortcut                           
Ctrl+U              EditorMakeLowercaseShortcut                   
Ctrl+Up             EditorScrollUpAndMoveCaretIfNecessaryShortcut 
Ctrl+V              Paste1Shortcut                                
Ctrl+W              CloseRunspaceShortcut                         
Ctrl+X              Cut1Shortcut                                  
Ctrl+Y              EditorRedoShortcut1                           
Ctrl+Z              EditorUndoShortcut1                           
F1                  F1KeyboardDisplayName                         
F1                  HelpShortcut                                  
F10                 StepOverShortcut                              
F10                 F10KeyboardDisplayName                        
F11                 StepIntoShortcut                              
F11                 F11KeyboardDisplayName                        
F12                 F12KeyboardDisplayName                        
F2                  F2KeyboardDisplayName                         
F3                  F3KeyboardDisplayName                         
F3                  FindNextShortcut                              
F4                  F4KeyboardDisplayName                         
F5                  F5KeyboardDisplayName                         
F5                  RunScriptShortcut                             
F6                  F6KeyboardDisplayName                         
F7                  F7KeyboardDisplayName                         
F8                  F8KeyboardDisplayName                         
F8                  RunSelectionShortcut                          
F9                  F9KeyboardDisplayName                         
F9                  ToggleBreakpointShortcut                      
Shift+Backspace     EditorDeleteCharacterToLeftShortcut           
Shift+Del           Cut2Shortcut                                  
Shift+Down          EditorSelectLineDownShortcut                  
Shift+End           EditorSelectToEndOfLineShortcut               
Shift+Enter         EditorInsertNewLineShortcut                   
Shift+F11           StepOutShortcut                               
Shift+F3            FindPreviousShortcut                          
Shift+F5            StopDebuggerShortcut                          
Shift+Home          EditorSelectToStartOfLineShortcut             
Shift+Ins           Paste2Shortcut                                
Shift+Left          EditorSelectToPreviousCharacterShortcut       
Shift+PgDn          EditorSelectPageDownShortcut                  
Shift+PgUp          EditorSelectPageUpShortcut                    
Shift+Right         EditorSelectToNextCharacterShortcut           
Shift+Up            EditorSelectLineUpShortcut 

3 comments:

aleksandar said...

PowerShell Magazine posted the article about ISE shortcuts too:

http://www.powershellmagazine.com/2013/01/29/the-complete-list-of-powershell-ise-3-0-keyboard-shortcuts/

Dave Carnahan said...

Thomas,

What is the value of $gps?

Thanks!

Thomas Lee said...

It was a line of code missing - now fixed.