views:

1718

answers:

8

Is there any way to automatically wrap comments at the 80-column boundary as you type them? ..or failing that, any way to display a faint line at the coulmn 80 boundary to make wrapping them manually a little easier?

Several other IDEs I use have one or other of those functions and it makes writing comments that wrap in sensible places much easier/quicker.

[Edit] If (like me) you're using Visual C++ Express, you need to change the VisualStudio part of the key into VCExpress - had me confused for a while there!

+12  A: 

Take a look at the question here: http://stackoverflow.com/questions/100420/hidden-features-of-visual-studio-2005-2008

It shows how to do that:

"Under "HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\Text Editor" Create a String called "Guides" with the value "RGB(255,0,0) 79" to have a red line at column 80 in the text editor."

Groky
should be 79, not 80. columns are 0-based.
mafutrct
@mafutrct: I've corrected his response
Jon Cage
+1  A: 

HKCU\Software\Microsoft\VisualStudio\9.0\Text Editor\Guides = [REG_SZ] "RGB(192,192,192) 80" (Looking at my 8.0 registry, so I'm not 100% certain)

MSalters
+2  A: 

See Blogpost from Sara Ford: http://blogs.msdn.com/saraford/archive/2004/11/15/257953.aspx

Anheledir
+2  A: 

In order to make Visual Studio text editor show a faint line on the 80th column you open RegEdit and locate the following:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editor

Please notice that 9.0 is for Visual Studio 2008. You should put 8.0 if you have Visual Studio 2005.

You create a new String value named Guides and enter the following value:

RGB(128,0,0) 80

You can adjust the RGB color to the value you like. The number 80 is the column you want the line to appear at. You can add another line (although I don't see how this can help) like that:

RGB(128,0,0) 2,80

This will make two lines appear, one at the 2th column and one at the 80th column.

Petros
I would change HKCU for HKEY_CURRENT_USER to make it absolutely clear what you're specifying..
Jon Cage
Thanks Jon, I've changed that.
Petros
+3  A: 

For Visual C 2008 Express users (like me) you'll need:

HKEY_CURRENT_USER\Software\Microsoft\VCExpress\9.0\Text Editor

Add a string value called Guides with the following value (as per the other responses):

RGB(180,180,255) 80
Jon Cage
A: 

By the way, in addition to the rightmost guide as per comments above, I also set lower contrast guides for columns 4, 8, 12, 16 etc. This really helps with code readability.

Chris Ballard
Interesting idea.. have you ever tried http://e-texteditor.com/ ? ...it can optionally put ...'s to indicate 4-space indentation points. This makes editing Python in particular much easier :)
Jon Cage
+2  A: 

This is provided as a sample macro:

Macros.Samples.VSEditor.FillCommentParagraph

The first time you run it it'll ask you what fill width you want (i.e. 80). I bind this to Alt-Q since I'm an Emacs refugee. After that you just move into the comment you want to format, run the command, and it'll wrap your comments suitably.

It ain't perfect, but it's pretty good.

David Stocks
Thanks David - that's rather handy!
Jon Cage
A: 

SlickEdit Tools for Visual Studio. There is a very good real time comment wrapper that automatically adjust length of lines as you type.

http://www.slickedit.com/products/slickedit-tools

Samuel