Editor Auto-formatting - prevent formatting for regular expressions, where-object, etc

Use this forum to ask about non-product related topics (login issues, product registrations, web site questions, etc.) No technical support questions, please.
Forum rules
Do not post any licensing information in this forum.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
This topic is 3 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
hkystar35
Posts: 2
Last visit: Fri Jun 19, 2020 6:41 am

Editor Auto-formatting - prevent formatting for regular expressions, where-object, etc

Post by hkystar35 »

Is there a way to suppress auto-formatting for specific functions/cmdlets/regular expressions?
I love the formatting, especially the automatic formatting options. But I really think it looks awful when expressions and Where-Object calls are formatted to multiple lines:

I would like to exclude Where-Object or expression blocks from formatting because this is more readable:
  1. $Array = $Otheraray | Where-Object {$_.Property -eq $Value}
  2. $Array | Select-Object @{L = "NewValue"; E = {$_.Property -replace '10', '11'}}
than this:
  1. $Array = $Otheraray | Where-Object {
  2.     $_.Property -eq $Value
  3. }
  4. $Array | Select-Object @{
  5.     L                              = "NewValue"; E = {
  6.         $_.Property -replace '10', '11'
  7.     }
  8. }
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Editor Auto-formatting - prevent formatting for regular expressions, where-object, etc

Post by brittneyr »

You can change the format settings in Options:
SPS_OptionsFormat.png
SPS_OptionsFormat.png (38.63 KiB) Viewed 2642 times
Brittney
SAPIEN Technologies, Inc.
hkystar35
Posts: 2
Last visit: Fri Jun 19, 2020 6:41 am

Re: Editor Auto-formatting - prevent formatting for regular expressions, where-object, etc

Post by hkystar35 »

I'm very aware of the formatting settings, which is why I asked if there's a way to create an exception to the formatting rules for specific cmdlets/functions/expressions.
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Editor Auto-formatting - prevent formatting for regular expressions, where-object, etc

Post by brittneyr »

There currently is no way to set specific formatting rules. You are welcome to file a feature request here and we will see what we can do:
https://www.sapien.com/requests
Brittney
SAPIEN Technologies, Inc.
This topic is 3 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.