Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

has anyone played with the powershell formatting in the VSCode PowerShell extension?

$
0
0

howdy y’all,

i’ve been waiting for the v0.9.0 version of the VSCode PowerShell extension to come out. it is out and the doc formatting works well. seems fast, but i haven’t any L-O-N-G scripts to test that on.

i’m hoping some others will want alternate indent styles. it uses K&R and has an option to switch to what looks like Allman. i prefer whitesmith, tho.

what i want …

if ($TestBool -eq $True) { Write-Output '$TestBool is TRUE.' } elseif ($TestBool -eq $False) { Write-Output '$TestBool is FALSE.' } else { Write-Output '$TestBool appears to be non-boolean.' } 

what the default settings give …

if ($TestBool -eq $True) { Write-Output '$TestBool is TRUE.' } elseif ($TestBool -eq $False) { Write-Output '$TestBool is FALSE.' } else { Write-Output '$TestBool appears to be non-boolean.' } 

there is a builtin, documented setting to move the opening brace to a new line. there doesn’t seem to be any way to control the brace/sub-control indent, tho.

i’ve found what i think is their indent code, but it’s a javascript [typescript] regex that twists my mind into knots. it’s here …

vscode-powershell/main.ts at develop · PowerShell/vscode-powershell
https://github.com/PowerShell/vscode-powershell/blob/develop/src/main.ts

lines 48 and 50 look likely. [grin]

however, i can’t figure out what is actually happening there. so i can’t even begin to guess what would need changing to get it to indent the closing brace to the same level as the code in a code block. [blush]

anyone willing to gimme some pointers?

take care,
lee

submitted by /u/Lee_Dailey
[link] [comments]

The post has anyone played with the powershell formatting in the VSCode PowerShell extension? appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Latest Images

Trending Articles



Latest Images