Skip to content

Conversation

@bergmeister
Copy link
Contributor

Add the following VS Code settings to have a more consistent PowerShell style already at the PR stage. It is mainly based on the K&R/OTBS style, which basically means braces are on the same line and that else, catch, and other keywords are "cuddled" (e.g. } else {)
Personally I'd prefer rather the Stroustrup style where there is no "cuddling" but I have seen that the K&R/OTBS is used more often in the codebase.

  // Sets the codeformatting options to follow the given indent style in a way that is compatible with PowerShell syntax. For more information about the brace styles please refer to https://github.com/PoshCode/PowerShellPracticeAndStyle/issues/81.
  "powershell.codeFormatting.preset": "OTBS",
  
  // Adds a space between a keyword and its associated scriptblock expression.
  "powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
  
  // Adds a space between a keyword (if, elseif, while, switch, etc) and its associated conditional expression.
  "powershell.codeFormatting.whitespaceBeforeOpenParen": true,
  
  // Adds spaces before and after an operator ('=', '+', '-', etc.).
  "powershell.codeFormatting.whitespaceAroundOperator": true,
  
  // Adds a space after a separator (',' and ';').
  "powershell.codeFormatting.whitespaceAfterSeparator": true

@rkeithhill
Copy link
Collaborator

rkeithhill commented Nov 23, 2017

When I last touched that file I considered adding these settings but I noticed that the PowerShell script in this repo is not terribly consistent style-wise. I like the idea of it being more consistent but this PR would make it easier for folks using VSCode to mix semantic changes with style changes.

I wonder if it would be better to just take the "styling" hit once and make all the script files conform to this style setup?

@bergmeister
Copy link
Contributor Author

bergmeister commented Nov 23, 2017

One could apply the styling to the files since VSCode has the Ctrl+K+F shortcut for that. But this is certainly a decision and probably action that the PowerShell team has to make.

@SteveL-MSFT
Copy link
Member

I'm fine with the proposed setting changes. We can apply the style universally after GA.

@daxian-dbw daxian-dbw merged commit f5b9942 into PowerShell:master Nov 28, 2017
@TravisEz13 TravisEz13 added this to the 6.0.0-GA milestone Nov 29, 2017
TravisEz13 pushed a commit to TravisEz13/PowerShell that referenced this pull request Nov 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants