Click here to monitor SSC

Richard Mitchell

Project Manager - Red Gate Software - http://cloudservices.red-gate.com
Development Factotum at Red Gate Software Ltd. Now working on a hosted system for maintaining cloud applications http://cloudservices.red-gate.com

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
Latest articles
A first look at SQL Server 2012 Availability Group Wait Statistics
 If you are trouble-shooting an AlwaysOn Availability Group topology, a study of the wait statistics... Read more...

SQL Server Prefetch and Query Performance
 Prefetching can make a surprising difference to SQL Server query execution times where there is a high... Read more...

SSIS Basics: Setting Up Your Initial Package
 When working with databases, the use of SQL Server Integration Services (SSIS) is a skill that often... Read more...

Checking Out SQL Backup Pro 7’s New Automatic Backup Verification
 Wouldn't it be great to offload the daily chore of checking the integrity of your production... Read more...

Chuck Lathrope: DBA of the Day
 Chuck Lathrope was a finalist for the Exceptional DBA of the Year award in 2009. We contacted him to... Read more...