Hotkey to run selection in PowerShell ISE is F8.
Hotkey to run selection in SSMS is CTRL+E.
For those of us constantly switching back and forth between the two, you know very well how many times we hit the “other” hotkey!
Well, now you can have the same key to run selection in both SSMS and ISE.
Jeff Hicks has written an article on creating new Hot Keys.
All I had to do to make CTRL+E run selection in ISE was “Google” it. I found this StackOverflow answer.
Here is the simple procedure:
- Open ISE
- Run”Notepad $Profile”
- Add below code to the end, save the file and restart ISE
# #Allow CTRL+E to run selection like F8 does # function invoke-selection { iex $psISe.CurrentFile.Editor.SelectedText } $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add( "Run selection", {invoke-selection}, 'ctrl+e')
You will also see this hotkey added to the bottom of the “Add-ons” menu in ISE. Now, you are all set to use CTRL+E to run selection within the ISE! You can even reassign other hotkeys that have been your pet peeves!
Update – Mar 22, 2016:
After using this for a bit, I found that this only works if the selection is all-encompassed and completely self-contained (without any dependencies on variables outside the selection). It is still great but I wish there was a way to get around the limitation. Also, instead of displaying the commands, it displays “invoke-selection” which can be distracting to some.