A guide-line for Visual Studio
And yes, I do mean that literally. :-)
Since starting this blog, 5 years ago – and even more in the last 2 years, since starting to develop and edit our Plugins of the Month for Autodesk Labs – I’ve been checking every line of code I’ve written to make sure it doesn’t exceed 70 characters in length (the magic number for fitting my blog’s width). It’s become close to automatic – in the sense I rarely write lines that exceed this length and therefore need adjusting – but the process I use is still quite manual: I check the status bar in Visual Studio to get the column count of the cursor position.
Augusto Gonçalves, from our DevTech team in Brazil, pointed out a nifty technique to add a guide-line (hence the post’s title) to Visual Studio at a certain column width. Here’s the Registry information (which can be saved to a .reg and merged with your Registry) that will do this for Visual Studio 2008:
Windows Registry Editor Version 5.00
Just changing the Registry information to 10.0 instead of 9.0 didn’t just make it work for Visual Studio 2010 on my system, despite information to the contrary on StackOverflow. But Daniel Du, from DevTech China, did point me to a handy Visual Studio extension (which comes in two parts and is described in this blog post).
After installing the two extensions, it was possible for me to add a guideline at a particular column width by placing the cursor at the desired width, right-clicking and selecting “Add guideline”:
Which leads to our guideline being displayed (with the selected colour):
Interestingly, looking at the Registry the extension is actually modifying the entry that didn’t seem to have an effect when entered via the .reg file, so I assume there’s an additional entry I was missing. But anyway – the end result is what’s important, and this will save me a lot of effort. And hopefully some of you, too. :-)