Richard Mitchell

Software Engineer - Red Gate Software
Engine programmer and factotum.

Cut-n-paste your code nicely

Published Thursday, May 17, 2007 9:48 AM

One thing that has annoyed me quite a lot lately is the way that cut-n-paste code from visual studio 2005 fails to look nice in emails. Your tabs dissappear you very large line gaps for every new line in your code and it sets the text to be a very strange font. Now maybe it's just me and my usage of the ancient Outlook 2003 but this has always bugged me.

I do tend to send code snippits to quite a few people via email to clear up problems with programming for ANTS Profiler and SQL Toolkit (look ma' links). After prompting from Rob who works beside me you can fix this annoyance by pasting your code into Word and then cut and pasting from word into your email ( assuming your email is in HTML format ).

Voila! Robert's your fathers brother. Bingo! Yahtzee! The code looks just like it did in visual studio.

Now if only I could be bothered to write a macro or add-in which did it straight from Visual Studio it would be wonderful.

Comments

 

B_r_i_a_n said:

You need a copy-editor.
May 17, 2007 8:21 AM
 

Adam Machanic said:

Personally, I copy and paste into Notepad, then copy and paste from there into the final destination.  I hate how when you copy out of VS2005 or SSMS the colors and fonts stick around if you paste into an editor that can handle them.  Keep my text as pure as possible, thank you very much!
May 17, 2007 9:57 AM
 

Phil Factor said:

Gad sir, the new version of the Simple-Talk Prettifier will do C#, VB and SQL and looks damn fine in emails. I use it the whole time.
You can find it here
http://www.simple-talk.com/prettifier/default.php
May 17, 2007 10:54 AM
 

Kirsty Burgess said:

Under Tools > Options, click the Mail Format tab. Then, under Message format, select Use Microsoft Office Word 2003 to edit e-mail messages.

This way, you skip the Word part and you can copy code from the Visual Studio editor into your e-mail.
May 17, 2007 11:00 AM
 

Richard Mitchell said:

Ewwww no. I generally send pure text emails anyway but occasionally it's nice to send people pretty code and that's pretty much all I'd use fancy fancy la dee da posh formatted emails :)
May 18, 2007 2:06 AM
 

RobertChipperfield said:

Phil: very cool, but it gets confused by the ternary operator:
   int foo = somebool ? 1 : 2

Results in:
   "[SQL Server]Error: unrecognisable token'? 1 : 2'"

Looks like a rather cool idea though, I like!
May 18, 2007 2:09 AM
 

Phil Factor said:

the 'definitive' list of c# keywords I used was missing the '?' and I was too stupid to notice! It should be fixed on the site by monday!
May 18, 2007 7:57 AM
You need to sign in to comment on this blog

















<May 2007>
SuMoTuWeThFrSa
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789
Virtual Exchange Servers
 Microsoft now supports running Exchange Server 2007 in server virtualization environments, not just on... Read more...

Virtualizing Exchange: points for discussion
 With the increasing acceptance of the use of Virtualization as a means of providing server... Read more...

Encouraging .NET Reflector Add-ins
 Jason Haley is well-known for the resources he's provided to developers who wish to extend Reflector's... Read more...

Using .NET Reflector Add-ins
 .NET Reflector by itself is great, but it really comes into its own with the help of some add-ins. Here... Read more...

Unique Experiences!
 You'd have thought that a unique constraint was an easy concept - Not a bit of it; it can cause a lot... Read more...