13

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!

Jon Cage
  • 36,366
  • 38
  • 137
  • 215

9 Answers9

14

Take a look at the question here: Hidden Features of Visual Studio (2005-2010)?

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."

Community
  • 1
  • 1
Grokys
  • 16,228
  • 14
  • 69
  • 101
8

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
  • 81
  • 1
  • 1
3

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
  • 36,366
  • 38
  • 137
  • 215
2

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

Anheledir
  • 4,337
  • 7
  • 32
  • 34
2

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
  • 8,862
  • 3
  • 39
  • 38
1

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
  • 173,980
  • 10
  • 155
  • 350
0

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
  • 3,771
  • 4
  • 28
  • 40
  • 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 Sep 26 '08 at 23:25
0

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

0

Take a look at http://www.kynosarges.de/CommentReflower.html.

Comment Reflower for Visual Studio

Comment Reflower is an essential add-in for Microsoft Visual Studio that provides configurable automatic reformatting of block comments, including XML comments.

Roger Dahl
  • 15,132
  • 8
  • 62
  • 82
  • Tool looks useful for some comment styles. Did not suit my requirement though of: /\* line1 \*/ /\* line 2 \*/ because there is no field to specify line end characters in the settings. Also does not do it in real-time, meaning you have to select the text and then select format. SlickEdit works great for wrapping the text as you go, but if you remove text from the comment block it does not move text from the previous line up, also does not add new text to the following line if there are already comments there, it simply adds a new line and pushes the other comments down. – Samuel Oct 12 '12 at 21:07
  • I used to think that it was important to thoroughly comment the code. Then I read *Clean Code* by Robert C. Martin. – Roger Dahl Oct 13 '12 at 00:31