VisualStudio and ISE Steroids Vertical Guides

To make it easier for reviewers and other programmers to read PowerShell code it is recommended that lines of PowerShell code don’t exceed 100 characters. If you run past this limit you should usually split the line using a backtick (`). I also find that this limit prompts me to rethink my code logic if the line gets too long. Besides, no one wants to have to scroll several pages horizontally to be able to read your whole line of code.

However, one of the most common issues I run into when reviewing (or writing my own) PowerShell DSC resources is going over the 100 character limit. For your own projects you’re most welcome to use any styles that you want (although I’d still recommend this one for the reasons above). However, if you’re going to commit this code to the PowerShell DSC community resources you’ll need to ensure your code meets this requirement, otherwise reviewers will likely ask you change it.

But there is an easy way to help identify this problem if you’re using Visual Studio Code or PowerShell ISE Steroids: Setup a vertical guide/ruler at 100 characters.


A nice easy to see vertical ruler/guide tells us when our lines get too long… oh dear this line is too long.

To Set up a Vertical Ruler in Visual Studio Code

  1. Select User Settings (you can use Workspace Settings if you want) from Preferences in the File menu:
  2. Your user settings.json file will load on the right, with the Default Settings on the left:
  3. Add the following line to your settings.json file in between the braces:
    "editor.rulers": [100]


  4. Save the file and restart Visual Studio Code.

To Set up a Vertical Ruler in ISE Steroids

  1. Select Show Secondary Toolbar from the View menu.ss_verticalruler_isesteroidsmenu
  2. Click the Vertical Guides button and select Global Guide…ss_verticalruler_isesteroidsverticalguidebutton
  3. Enter 100 in the input box and press enter.


    The vertical guide is added – better fix that long line!

That is all there is to using vertical guides. Having them setup if you’re planning on committing code to a community project might save you some extra commits and help the community reviewers merge your code faster.

Happy coding!



4 thoughts on “VisualStudio and ISE Steroids Vertical Guides

  1. For PowerShell scripting in VSCode I also highly recommend this setting:

    “files.trimTrailingWhitespace”: true,

    And if you’re a spaces (instead of tabs) type of scripter:

    “editor.insertSpaces”: true,


  2. James Baker says:

    I’m here from a PR review 😉

    OOI google limit the line length to 80 chars:

    Each line of text in your code should be at most 80 characters long.

    We recognize that this rule is controversial, but so much existing code already adheres to it, and we feel that consistency is important.

    Those who favor this rule argue that it is rude to force them to resize their windows and there is no need for anything longer. Some folks are used to having several code windows side-by-side, and thus don’t have room to widen their windows in any case. People set up their work environment assuming a particular maximum window width, and 80 columns has been the traditional standard. Why change it?

    Proponents of change argue that a wider line can make code more readable. The 80-column limit is an hidebound throwback to 1960s mainframes; modern equipment has wide screens that can easily show longer lines.

    So you could argue 100 is too long. Also could you see this changing with more people using 4k screens? I can fit 416 chars on a 4k @ 125% vs 269 on a 1080p @ 100% so in the future it could be 120?


    • Hahaha LOL 🙂 I’ll adjust my post and recommit!

      I actually prefer a line length of about 120 chars, because I usually have two code panes side by side and that fits best. But in this case the 100 char limit is simply because that is what is set in the for DSC.:) I think if the Styleguidelines say to use some line limit then using the vertical guides is an easy way of checking it.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s