Colin Bacon, web developer.

Make your code more readable on GitHub | Visual Studio

Make your code more readable on GitHub | Visual Studio

There is nothing more frustrating than having to horizontal scroll a file on GitHub. It doesn't make for a happy user experience. Not for me anyway.

The file viewer on GitHub is limited to 140 columns before it overflows and you have to scroll vertically. I find this really frustrating when looking at code in other projects. You have to remember your position in the file, scroll down to be able to vertically scroll and then scroll back up to see the rest of the code. Whilst I may not be able to change other people's code, I make sure mine falls within the 140 columns. There are a couple of things you can do.

Editor Guidelines extension for Visual Studio


This extension adds vertical column guides. You can specify where the guides are positioned and what colour they are. I have one set to 140 columns making it obvious when my code is going to overflow on GitHub.

Resharper Line Breaks and Wrapping options

If you have Resharper you can set the maximum column width before automatically wrapping long lines. This can be set from the Visual Studio toolbar:

ReSharper > Options > Code Editing > C# > Formatting Style > Line Breaks and Wrapping

I have both options set up in Visual Studio. I appreciate the visual cue of the guideline and I love the automatic wrapping that Resharper gives me. More importantly I feel happy that my code will be readable to all on GitHub.