Today I was playing with PowerShell v3 and was frequently working inside ISE (love it’s Intellisense feature). I was in this situation few times:

Cursor at position zero

As you can see, cursor is at position 0. At this time I want to add new line, so it means go to end of current line and press Enter. I wanted to automate it. Fortunately ISE object model is self-descriptive, so I created this small Add-on:

$psise.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(
'Insert line below',
    {
    $psise.CurrentFile.Editor.Select(
        $psise.CurrentFile.Editor.CaretLine,
        $psise.CurrentFile.Editor.GetLineLength($psise.CurrentFile.Editor.CaretLine)+1,
        $psise.CurrentFile.Editor.CaretLine,
        $psise.CurrentFile.Editor.GetLineLength($psise.CurrentFile.Editor.CaretLine)+1)
    $psise.CurrentFile.Editor.InsertText("`n")
    }, "CTRL+ENTER")

$psise.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(
'Shift line',
    {
    $psise.CurrentFile.Editor.Select(
        $psise.CurrentFile.Editor.CaretLine, 1,
        $psise.CurrentFile.Editor.CaretLine, 1)
    $psise.CurrentFile.Editor.InsertText("`n")
    $psise.CurrentFile.Editor.Select(
        $psise.CurrentFile.Editor.CaretLine-1, 1,
        $psise.CurrentFile.Editor.CaretLine-1, 1)
    }, "CTRL+SHIFT+ENTER")

I added two features: add line below and before (shift line). You can call it either from menu:

Add-on menu

or via keyboard shortcuts.