Are there any VS.NET plugins that will format a selection of code for printing or emailing and is also free?
Have you checked the inbuilt formatting provided by VS? Select code and enter key chord Ctrl+K, Ctrl+F.
Or goto (menu)Edit->Advanced->FormatSelection or Edit->Advanced->FormatDocument
That doesn't do anything. The code looks fine in the editor. It's when you paste it somewhere else or try to print it that there are problems. Mainly because of the identing. The method signature might be all the way to the left but your method body floats off to the right.
If you copy your code from Visual Studio and paste it into Word, the syntax highlighting will be kept.
Alternatively, you could take a look at the Copy Source As HTML add-in.
Is this just a matter of using spaces instead of tabs to do indent your code?
Use some kind of tabs-to-spaces function, and make sure the print or email uses a monospaced
(aka. typewriter or console) font.
I'm pretty sure VisualStudio had a (little well hidden) function to convert indenting from tabs to spaces and vice versa.
I'm normally using vim where you can use:
:set expandtab
:%retab
to replace tabs with spaces and:
:set noexpandtab
:%retab
to replace spaces to tabs.
Spaces is better for emailing etc. because noone can agree on the length (in spaces) of a tab.
try Artistic Style 1.22, http://astyle.sourceforge.net/
it's easy to use, has 3 or 4 predefined styles and is configurable.
To turn tabs to spaces, select the code and use Editor -> Advanced -> Untabify Selected Lines
.