DetentShell The PowerShell 7 ISE we should have been delivered 8 years ago*

Format / Indent

DetentShell's planned Format/Indent button reindents a script with PSScriptAnalyzer's own formatter. Designed and built, not yet in a shipped release.

DetentShell logo
Format / Indent Coming soon

One click reindents and tidies your whole script, using PSScriptAnalyzer’s own formatter (Invoke-Formatter). Keep it light, indentation only, or go full format. Either way it’s a single undo.

Not shipped yet

This feature is designed and built, but it hasn’t landed in a released version of DetentShell yet. It lives in the Edit menu and on the toolbar in the current development build. When it ships, this page updates to say so and the changelog records it.

The toolbar icon

Steel text lines with the lower two stepped to the right, and a blue arrow marking the indent. It sits in the Edit menu as Format Document (Shift+Alt+F), and on the toolbar next to the other editing actions.

Two behaviors, one engine

Both modes are real, and both run through the same formatter. Which one the button uses is a single setting, Format / Indent button applies: in Tools > Settings.

Three real examples

Every before/after pair below ran through the actual formatter.

Messy indentation, cleaned up

Both modes produce this result.

Before

function Get-LargeFiles{
param([string]$Path,[int]$MinMB=1)
$files=Get-ChildItem $Path -File
foreach($f in $files){
if($f.Length -gt ($MinMB*1MB)){
Write-Output $f.FullName
}
}
}

After

function Get-LargeFiles {
    param([string]$Path, [int]$MinMB = 1)
    $files = Get-ChildItem $Path -File
    foreach ($f in $files) {
        if ($f.Length -gt ($MinMB * 1MB)) {
            Write-Output $f.FullName
        }
    }
}

Where the two modes differ: brace style

Already indented, using Allman braces.

Before

function Test-Server
{
    param($Server)
    if (Test-Path $Server)
    {
        return $true
    }
    else
    {
        return $false
    }
}

Indentation focused: brace style untouched (no change here)

Full format: restacked to one true brace

function Test-Server {
    param($Server)
    if (Test-Path $Server) {
        return $true
    }
    else {
        return $false
    }
}

A full-format extra: aligned assignments

Before / indentation focused

$server = "sql01"
$port = 1433
$database = "master"
$timeoutSeconds = 30

Full format

$server         = "sql01"
$port           = 1433
$database       = "master"
$timeoutSeconds = 30
See it in context

The rest of the editor →  ·  What else is planned →  ·  The changelog →

Get DetentShell
PS> Start-Process "https://detentpoint.com/detentshell/download"
# Coming soon — ships once the installer is code-signed

Coming soon. DetentShell launches at $29.99 in the Microsoft Store for its first two weeks. The regular price that follows is not final yet and will be published here first; volume licensing for teams is handled separately.

Follow progress on the changelog →