#PSTip Transposing lines in PowerShell ISE

Note: This tip requires PowerShell 3.0 or above.

When working in the ISE editor you sometimes need to rearrange lines of code and move them below or above other lines. The natural process is to highlight a line, cut it, move your cursor position to another position and then paste.

In ISE 3.0 there’s a hidden keyboard shortcut that can save you a lot of key strokes and make the process a lot easier. Consider the following content. You want to move the first line two lines below.

All you need to do is place your cursor anywhere inside the first line and press the Alt+Shift+T key combination twice. Try it.

Unfortunately, you can only swap lines in one direction only, from top to bottom. There is no keyboard shortcut to do the opposite.

About the author: Shay Levy

Shay Levy is a Co-founder and editor of the PowerShell Magazine. He is a multiple-year recipient of the Microsoft MVP award, and a Microsoft Certified Trainer (MCT). Shay often covers PowerShell related topics on his blog and you can also follow him on Twitter at @ShayLevy

Related Posts

%d bloggers like this: