Customizing Visual Studio – Shortcuts to Commands

One of the great things about Microsoft is the way all of their stuff is extensible. For years folks have been writing macros, add-ins for the office tools. In case you hadn’t noticed, Visual Studio is just as extensible as the rest of the Microsoft tools.

In this first article, we’ll look at making a shortcut to a handy VS command. First, we’ll need to fire up SlickEdit Gadgets Command Spy tool. What? You haven’t installed it yet? OK, go read my blog posting from November 14th (https://arcanecode.wordpress.com/2006/11/14/visual-studio-add-ins-slickedit-gadgets/ ). The rest of us will wait.

Back now? Great. OK, as I was saying fire up Command Spy. You’ll see it’s window appear, just slide it to an out of the way space, or dock it. In this example, we’ll want to create a shortcut toolbar to collapse and expand all of our code regions with one click.

There’s already a menu option to do this, click on Edit, Outlining, Collapse To Definitions. (Note if you don’t see the Outlining option, make sure you’ve clicked in the code window.) Glancing down at the Command Spy window, you will see that the command issued was Edit.CollapseToDefinitions.

[CommandSpy First Command]

Great, jot that down, and let’s run another command. Click on Edit, Outlining, Toggle All Outlining. You’ll see a new command has shown up in Command Spy.

[CommandSpy with Second Command]

Edit.ToggleAllOutlining is what we are looking for here. Now that we have the commands we want, let’s create a toolbar and hook them in.

Right click in the toolbar, and select Customize. In the Customize dialog, click on New. Give your toolbar a good name, it’s also helpful if you use something like your name to distinguish it from the rest of the built in bars. I named it ArcaneOutlining. You’ll see your new toolbar pop up to the right of the Customize window. (The red arrow is pointing at it.)

[Create a new Toolbar window]

I’m now going to drag the new toolbar under the Customize window, just so it will look decent for the next screen capture.

Now we need to drag our commands onto the toolbar. Click on the Commands tab of the Customize window. Under Categories, scroll down to Edit. Now in the Commands list area, scroll down to Outline Toggle All, and drag it onto the toolbar. Then, pick Outline Collapse to Definitions, and drag it into the toolbar. In this shot, you’ll see what it looks like when you’re done.

[Customize the toolbar window]

OK, we now have our commands, but all that text looks pretty ugly. Right click on the Outline Toggle All command, and you’ll get a menu. Click in the Name area, and you can type over the name of the menu option. I’m going to replace Outline Toggle All with + (a plus sign).

[Rename menu]

Once done, close the Customize dialog, then you can drag your toolbar to an appropriate spot. Use the – button to collapse everything, and the + to toggle it back.

[Picture of our new toolbar]

While I’ve picked out some specific commands, you can use this technique for any command that Visual Studio can produce, and create your own customized toolbars.

Visual Studio Add-Ins: VSFileFinder

If you tend to organize everything in your projects using file names, then you will love this add-in. VSFileFinder, available at http://www.zero-one-zero.com/vs/, adds a simple window to your Visual Studio environment. I elected to dock this window in the bottom center, where my output sits. There’s a text box across the top and a list box under it.

[Picture of VSFileFinder]

 

The text area lets you key in a file name (or part of one) to filter off of. The list area shows all the files in your project that match the entered filter. Clicking on a file will let you open it, or if already open will bring it to the foreground.

As you can see, entering “fo” matched all my Form1 files. Interestingly enough it also matched AssemblyInfo since it also contains “fo”.

That’s about it, VSFileFinder is a simple, one task tool that adds one specific type of functionality. But it does it well, and for free!

 

Visual Studio Add-Ins: Cool Commands 3.0

Update Feb. 9, 2008: Version 4 is now out, but there’s no new blog post. Follow the link below and scroll down through the comments to find the link to version 4.

Another handy add-in that brings functionality to the Solution Explorer is CoolCommands. Version 3 is available from http://weblogs.asp.net/gmilano/archive/2006/05/10/446010.aspx, and adds a whole series of new menu commands to the right click menu in the Solution Explorer window. It also adds a few new menu command to the Code Editor window. Since the site doesn’t do a great job of documenting all the features in the current release, here is a brief list of all the commands that get added.

Commands for the Code Editing Window

DemoFont – In the edit window, right clicking has a new menu option called DemoFont. This will let you quickly toggle back and forth to a larger size of the font you’ve been running. Clicking again will return you to the font size you previously had.

Wheel Font Zooming – My guess is this lets you use the mouse wheel to adjust the font size, but it didn’t work on my system. However the other commands are so useful I’m willing to overlook one dud.

Open File – This is very cool. Within comments you will sometimes see something like “// See the class file Xyz.cs for more info”. With cool commands, you simply right click on Xyz.cs and pick Open File, and that file will open in VS.

Commands for the Solution Explorer

Collapse All Project – Simple menu option to collapse all the projects in your Solution Explorer’s tree.

Command Prompt Here – Opens a command window in the directory where the project sits. (Only appears when clicking on a project).

Open Container Folder – Opens a Windows Explorer where the current file happens to reside.

Reference Manager – Lets you manage the references for the solution.

Resolve Project References – Validates all of your project references.

Copy and Paste References – Lets you create a reference for one project and paste it into another project. Makes setting up references between projects nice and easy.

Add Projects From Folder – Allows you to easily import one or more projects that are stored in a folder.

Commands for the open files tabs

Locate in Solution Explorer – This is cool, in the little tab markers at the top of the editing window, right click and pick this option. The solution explorer will then highlight the file for you.

One thing to note, technically CoolCommands is not an Add-In. While it adds new menu options, it cannot be loaded or unloaded from the Tools, Add-In Manager.

This free tool adds some nice functionality to your VS environment, and is well worth the download.

Visual Studio Add-Ins: Explorer

My next find for a Visual Studio Add-In is called Explorer, and is another free one available from http://www.codeproject.com/csharp/Explorer.asp . Explorer is easy to install and use.

After you download, extract the two files to your My Documents/Visual Studio 2005/Addins directory (create the Addins directory if it doesn’t exist). Then launch Visual Studio, click on Tools, Add-in Manager, and make sure Explorer is loaded.

Using Explorer is quite simple, just right click on the Solution, Project, or a folder and you’ll see a new menu option, Explorer.

[Picture of Explorer Menu]

 Explorer has a submenu with two options, “Open folder” and “Execute this application”. Open folder opens up a windows explorer folder in the same directory where the item you clicked on resides. This is a very handy way to quickly navigate to the directory where your project resides.

Note the “Execute the application” option only appears when you are on a project, not the solution. However, this is handy when you have a test project that is not your main application. Using this menu option keeps you from having to go through the effort of changing your startup project to run a rest program that is part of your solution.

Be aware this does not build the project, it runs the last built exe you created. If you’ve made changes to the project you want to run be sure to do a build before using this menu option.

If you are interested in writing your own add-ins, you should also check out the available source code. It’s a nice example of how to hook into the menu structures for writing your own add-ins.

Robert Scoble is a Space Alien and I’m Carrying His Love Child

[Picture of Tony Robbins] Self help guru and life trainer Anthony Robbins (http://www.anthonyrobbins.com/) talks about a principle he calls CANI, Constant And Never ending Improvement. As part of my process of continuous self improvement I was looking for advice on writing a better blog.

[Love Child] First let me set the record straight, I’m not really carrying Scoble’s love child. It can walk (well, slither) just fine on it’s own, thank you very much. And the space alien thing is just a rumor. Really. Any resemblance between the love child (above) and Scoble (below) is purely coincidental, antenna not withstanding.

[Robert Scoble - Space Alien??]In a recent post (http://scobleizer.com/2006/12/07/help-a-san-jose-mercury-news-columnist-blog/) Robert was giving some helpful hints to journalist Mike Cassidy (http://www.mercextra.com/blogs/cassidy/) on how to attract folks to his blog. Some really great tips, including using a catchy, controversial name for your entries. Oh, something like “Robert Scoble is a Space Alien and I’m Carrying His Love Child”.

In his advice, Mr. Scoble also suggests making the subtitle of your blog more meaningful, and focused on your target audience. This is good advice that I have implemented. You may notice in my header I’ve changed from “Computer Sorcery at it’s Best” to “Making Microsoft .Net Development Magical” which isn’t as catchy but does a much better job of describing the general theme of my blog. Of course this isn’t the first time Scoble has dispensed blogging advice, he has good information in his Naked Conversations work. (See http://redcouch.typepad.com/weblog/2006/08/9_random_though.html ).

Robert’s not the only one in the family with good advice on blogging either. His lovely wife Maryam had a great post on her site titled 10 Ways To Write A Killer Blog: http://maryamie.spaces.live.com/Blog/cns!9592F3DEF41537A3!2373.entry#comment )

Looking for other good advice, I found an excellent post from someone named Helen’s. Her post “Increasing Traffic To Your Blog” can be found at http://imhelendt.wordpress.com/2006/09/16/increasing-traffic-to-your-blog/ . Over at ProBlogger, they have created a whole page full of good articles called “Blogging for Beginners” (http://www.problogger.net/archives/2006/02/14/blogging-for-beginners-2/). Even if you are not wanting to make money from your blog, there is still a lot of good info here.

Dennis Mahoney has some good advice on writing for the web in his post “How To Write A Better Weblog” (http://alistapart.com/articles/writebetter/ ). While his advice is aimed at the blogger, overall it is sound for any form of written communication.

I’d like to wrap this up with a little advice of my own. First and foremost, offer value. One of my goals is to offer readers a little something extra that they might not find elsewhere. Perhaps it’s through consolidating information, like I’ve done here, or providing details that I have not seen elsewhere in the blogosphere, like my Virtual PC Step by Step entry.

My next piece of advice would be to write nearly every day. Consistency is the key to creating an effective blog and attracting an audience. It’s very disheartening to find what looks like it could be a good blog, but seeing it only gets updated once a month. I create new entries every week day, generally taking the weekends off.

The number of entries you post in a day is up to you, and the nature of your blog. Since I like to teach and try to do that through my blog, I tend to post one new item a day. Mike Cassidy (see link above) has a news oriented blog, so he too would typically want to present one story a day unless there was breaking news of some kind. Robert Scoble, however, tends to produce many entries a day because his blog is a mixture of quick newsbites mixed with personal observations.

If writing every day seems a bit too much, then do a weekly blog, or do what I do write up your entries in advance and then post one a day. As I mentioned, consistency is the key.

Finally, even if you are not interested in writing your own blog, I would encourage you to read through some of the links I’ve included. It will help you in providing quality feedback in your comments, and I highly encourage you to leave comments! It’s very helpful to us bloggers to hear what’s on your mind, if you found our items useful, and what we can do to make it better.

Command Prompt Explorer Bar

OK, I admit it. I’m an old time command line junkie. Starting out in the old DOS days I still find it faster to do some tasks by pulling up a command window and

This is a tool that’s been around for a while, but I find few people know about. Have you ever been in an explorer window and wished you had a command prompt that you could easily cut and paste between? Command Prompt Explorer Bar is your answer.

Available at http://www.codeproject.com/csharp/CommandBar.asp this tool has some cool features. After you install, open a new explorer window. Then hit Ctrl+M or select View, Explorer Bar, Command Prompt from the menu.

[Picture of Command Prompt Explorer Bar]

Down the left side are some handy short cut icons.

[Command Prompt Explorere Bars Shortcuts]

The top icon gives you the standard edit tools you’d have under a normal command window.

The second icon, the little green arrow, is the Synchronize command. If you’ve CD’d around, and want to quickly get back to the same folder as what are displaying in the upper half of the explorer window, just click the Synchronize tool.

The next tool, the one that looks like a blank window, is the CLS command. For those of you who are not a command line junkies, CLS stands for CLear Screen, and basically wipes the display.

The button with green text is the “Get selected items” button. If you highlight one or more files / folders in the upper half of the explorer window, pressing this button copies the file / folder names to the command line. Very useful for passing files to batch jobs.

The fifth icon down looks like a yellow bent arrow is the enter command. Clicking it is just the same as hitting the enter key on your keyboard.

The next item is the ESC key command, it’s the one with red text. Like the enter button, this is the same as pressing the escape key on the keyboard. A lot of older command line programs use escape to exit their program.

The seventh button is a menu that will paste in popular commands, such as “cd..”. Note that it has some shortcuts for .Net. However, this app was last updated in 2002, so don’t expect these to work with VS 2005. However the source code is available for download, so perhaps someone will update this feature.

The bottom two buttons will expand and contract the width of the command window.

There you go, a cool free tool to help out all us old command line addicts.

 

 

Elbow Room

On the 6th Doncha posted a WordPress blog (http://wordpress.com/blog/2006/12/06/running-out-of-space/) saying you could upgrade your WordPress account, and get up to 10 gig of storage space. The main question was, what could you do with all that space?

As a developer I’d love to have a space to place my projects. Whether it’s a small sample, or a complete application I’m giving out, it’d be nice to be able to host in a place I have control over.

Next, I’ve been experimenting with some software to do videocasts. A videocast is a capture of your screen as you work, with an accompanying audio track. I think it would be great to be able to take my blog to the next level, with extra material.

Finally, I love digital photography. Some of the high quality images though have pretty hefty file sizes. I’d love to have a gallery to display by best works.

That’s what I’d use 10 gig for. Elbow room.