Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell indent here-string

Tags:

powershell

Does anybody know if it is possible to intend a here-string. Actually I've to write:

  $someString = @"
                First line
                second line
  "@

This becomes very ugly if you define a here-string on a deeper indentation level, because the ending "@ must be the first character on the line. Additionally somebody might "fix" the missing indentation and break the script ...

Is it possible to define a here-string like:

  $someString = @"
                First line
                second line
                "@

Thx

like image 898
Moerwald Avatar asked Jul 25 '17 06:07

Moerwald


1 Answers

The closing "@ must be at the start of the line.

I agree with you that this can make the script file harder to read, but it is the rule, and there is no way around it as far as I know.

You can find a uservoice entry here, and you should vote for it if you feel this is important to you. It does not look like a priority at the moment, with only 3 votes, but the more votes, the higher the priority for the powershell team to look into it.

like image 91
Dimse Avatar answered Oct 26 '22 23:10

Dimse