Smart Paster Makes Life Easier

You don't have to pay for everything you want. There are a lot of free tools out there that will may your life better. Obviously, when I get a free tool I don't look at the price. What I do look for is useful functionality, simple installation, a quick start and whether the tool fits with the way I work. I find that I'm more willing ignore "fit and finish" issues with a free tool.

Smart Paster is a good example. It's a tool that I use a lot. I'm constantly pasting strings into my programs and formatting them to work as string values. For C# this means breaking long strings up to concatenate them together and adding the @ prefix. Smart Paster adds a Paste As... option to the popup menu when you right mouse click in an editor window. If you pick the String choice in a C# file, this is what you get:

@"Smart Paster is a good example. " +
@"It's a tool that I use a lot. " 

In Visual Basic you get the line continuation characters:

"Smart Paster is a good example. " & _
"It's a tool that I use a lot. " 

You can customize how long your strings will be.

But wait, there's more! The other paste operation I do with strings is to create a StringBuilder. There's a menu choice for that, too. When you do a StringBuilder paste, you need to provide the name of your variable and this is what you get:

Dim sbArticleText As New StringBuilder(421)
sbArticleText.AppendFormat("Smart Paster is a good example.")
sbArticleText.AppendFormat("It's a tool hat I use a lot")

The tool even handles escaping embedded quotes. What are my complaints? A minor one: The choices that I use are on a submenu and I wish they were directly on the popup menu. A second minor complaint: I wish that double quotes were handled by replacing them with single quotes -- it would make it easier to paste XML into string constants.

My biggest issue is installing the package. The Visual Studio 2008 version is only available as source code and comes without installation instructions. Get your version here, which provides a compiled version and instructions on how to install it (you have to extract a zip file to the right place). This is one of those "fit and finish" issues that I'm willing to overlook in a free tool.

You can also paste into a Region and as a comment but I've never used them.

Posted by Peter Vogel on 04/16/2010 at 12:46 PM


Reader Comments:

Fri, Aug 13, 2010 Terry AZ USA

I would use this add-in sparingly, since best practices dictates using a resource file.

Tue, May 18, 2010 Peter Vogel Canada

Ah, there you've exposed one of my (many) weaknesses: I've never mastered regular expressions. And I've felt the lack, too.

Mon, May 17, 2010 Sean UK

I'm missing it a lot too, although I've found a that I can achieve the same effect with a regex and the "find and replace" tool which in some ways gives me more flexibility.

Tue, May 11, 2010 Peter Vogel Canada

Sean: I'm not aware of any version of Smart Paster for Visual Studio 2010--but I don't know that the current version won't work with VS 2010 (I'm in the midst of two mad deadlines using VS 2010 for clients right now so I'm not willing to take the chance of trying it with my copy of VS 2010). I'm hoping that, by the end of the month, I'll open up a window to try it. The source code is available and I know that the add-in model for VS 2010 hasn't changed much from VS 2008 so it should work. Hopefully, though, the author will have a new version out soon. In the meantime, I really (!!really!!) miss it a lot.

Mon, May 10, 2010 Sean

Do you know if there is a version of smart paster for VS2010 anywhere?

Add Your Comments Now:

Your Name:(optional)
Your Email:(optional)
Your Location:(optional)
Comment:
Please type the letters/numbers you see above