Here is the problem:
I have a few scripts that are thousands of lines long. When working with these scripts in ISE, I often start modifying some part of the code and then use scroll bar to move up and down to refer to other parts of the code. In this process, I, naturally, lose track of the cursor position where I was making changes. This happens quite often and started frustrating me. Of course, I can look at the status bar for the cursor coordinates and move to the cursor location manually. But, hey, ISE is extensible! So, I wrote a simple addon that takes me back to where the cursor is and re-focuses editor window at the cursor position by scrolling back to that place.
This is quite easy.
$addonName = "Go To _Cursor"
$addonkey = "Alt+C"
$ScriptBlock = {
$psise.CurrentFile.Editor.EnsureVisible($psise.CurrentFile.Editor.CaretLine)
$psise.CurrentFile.Editor.Focus()
}
$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add($addonName,$ScriptBlock,$addonkey) | Out-Null
Actually, this is it. You just add this to your profile and press ALT+C when you need to go back the current cursor position after using the editor scroll bar.





Pingback: PowerShell ISE v3 (CTP2) addon: Go to Input — Ravikanth Chaganti