Did you know… How the External Tools Tokens Work? – #205

Updated 30Apr2008: Note the binary directory is for Visual Studio 2008.

I’ve hinted at a few of the external tools tokens, but let’s explore a little more.  I think most of these are self-explanatory, and the help documentation explores each in depth, but here’s a high-level overview.

All of the Item and Current tokens (available for the Arguments edit box) operate on the currently-active editor.  Note the editor does not have to have focus in order to work, but just have (inactive) selection.

Item and Current Tokens

For the Initial Directory edit box, you’ll find all the directory tokens, but one in particular to call out is the Binary Directory.  Note:  This is new functionality for Visual Studio 2008.

Directory Tokens

The Target Directory token targets the obj directory (\obj\Debug\), but if you need the final bits that go into the bin directory (\bin\Debug\), use the Binary Directory token.

Did you know… you can have your External Tool’s text displayed in the Output Window? – #204

At the bottom of the External Tools dialog, you’ll see more options for customizing the external tool within visual studio.  Today’s tip is about the Use output window option.  The idea here is you’re running a .bat file, and you want to track the progress within Visual Studio.  (and if you have a great real-world example, please leave a comment.)

Using the command prompt as the tool, you can set the Arguments to something like “/C echo $(CurText)” where

/C – from cmd.exe, carries out the command specified by string and then terminates

and

$(CurText) is a token that comes from Visual Studio that represents the currently-selected text.

Current Text Token

Now running this external tool with a line of text selected in the editor, we get the following in the output window:

Command Prompt Output in Output Window

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… You can rearrange the list of external tools and create mnemonics? – #203

Continuing with the newly added notepad tool from Friday’s tip, you can use the External Tools dialog to sort your list of external tools as they will appear on the Tools menu.  To the right you’ll find the Move up and Move down.

External Tools Notepad Top of List

You can specify a mnemonic (also known as a keyboard accelerator) by putting an ampersand in the Title.

Notepad ampersand in title

Now under Tools menu, you can simply press ‘n’ to launch notepad.

Notepad with mnemonic

If there’s a mnemonic conflict, the focus will jump between (or among) all the commands that share that mnemonic, such that hitting enter will execute the command.  But it is ideal to have no conflicts.

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… You can add your own External Tools to the list? – #202

Go to the Tools – External Tools dialog, and you’ll see the Add  button. 

  1. Clicking Add will create a [New Tools 1] placeholder. 
  2. Let’s add Notepad as an external tool by calling it “Notepad” as the Title
  3. For the command, this is the actual executable (and location, if needed).  You should be able to just enter in “notepad.exe” depending on your environment variables.

Adding notepad to external tools

Now, this is the minimum you need to make an external tool work.  But let’s go a little further by exploring the optional arguments…

  1. For arguments, you can type in the name of a file, either existing (if you want notepad to open it) or the name of a file you want notepad to create.
  2. For initial directory, you can type in the file path, either where it exists or where you want it to save to.

And of course, we’ll see notepad in the Tools menu…

Notepad added to Tools menu

We’ll explore more of the arguments and other options in the upcoming tips… same RSS time, same RSS channel – for those of you who get the reference to the old batman tv series =D

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… You can run external tools within Visual Studio? – #201

It’s the External Tools Tip of the Day series!!

Okay I have to admit, I’m not the local expert in External Tools, so I could really use help with examples.  I can talk about the functionality all day long, but nothing is better than real world examples.

Let’s start with the basics.  Go to Tools – External Tools to bring up the External Tools dialog.  You’ll notice a set of built-in tools ready to go for you.

Tools - External Tools

Note that I circled the list of external tools.  This list maps directly to the list presented in the Tools menu, as shown below.

External tools listed on Tools menu

The first time I made this connection I was taken aback.  I probably saw this list of tools for years, but never knew it came directly from the External Tools dialog.

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… You can bind the show “Errors”, “Warnings”, and “Messages” buttons to keyboard shortcuts? – #200

WOW!  Tip number 200.  There are no words, except for “what a difference a day makes.”

I’m so excited about today’s tip.  (not because that it is tip #200 – this was purely coincidental), but because I accidentally found it while browsing the commands in the Tools Options Environment Keyboard page that contained “Error.”

Go to Tools – Options – Environment – Keyboard and search for Errors.  You’ll notice that this odd “Errors” command will stare back at you. 

Errors command

I say this “odd” command because usually Visual Studio commands have the format of <word>.<word> (i forget the actual terminology we use to describe commands.)  This obviously caught my eye, so I contacted the developer for confirmation.

These commands toggle the Errors, Warnings, and Messages shown on the Error List, so you can bind them to keyboard shortcuts.

 Error List Window buttons

For example, you could bind the following commands to…

Errors – CTRL+ALT+SHIFT+E

Warnings – CTRL+ALT+SHIFT+W

Messages – CTRL+ALT+SHIFT+M

Now, instead of clicking the buttons, you can just use the keyboard shortcut. 

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… You cannot enable the “stop search” on the Output Window? – #199

You may have noticed the “Stop Search” command on the Output Window context menu.  So, I spent a good 20 minutes trying to figure out how to enable this command, before i broke down and emailed the developer. 

Output Window Stop Search on Context menu

Apparently you can’t enabled it.  It’s because a lot of the Output Window and the Find Results window share a lot of implementation, and looks like it should have been hidden for the output window case.  So in case you ever noticed this and wondered… well, “Now we know and Knowing is half the battle!”

Speaking of the G.I. Joe cartoon series, in Best Buy the other night, I saw a DVD set for a season of Voltron on the shelf.  I nearly bought it when I realized it was for episodes 60-75ish.  Must buy season 1 now…

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… You can redirect debug messages to the output window? – #198

Depending on your environment settings (like the Visual Basic Default Settings), you may have noticed that the Output Window’s debug content is redirected to the Immediate window instead.  Or maybe you want the output window’s debug content to go to the Immediate window.

Go to Tools – Options – Debugging – General page.  Under this page, you’ll find the option Redirect all Output Window text to the Immediate Window.

Redirect output window debug to Immediate window option

To illustrate, let’s say you have this option enabled, and you hit an assert.  You’ll see the assert info in the Immediate window, and not in the output window.

Assert shown in the Immediate Window

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… You can use F8 and Shift+F8 to navigate among errors in the output window – #197

the General Development Settings, F8 and Shift+F8 are bound to Edit.GoToNextLocation and Edit.GoToPreviousLocation.

If you have the Error List open, F8 and Shift+F8 will take you directly to the error in question by highlighting that part of the code.  If you have the Output Window open, F8 and Shift+F8 will put the cursor on the beginning of each line for each error listed in the Output Window.

Output Window Go To Next / Previous Location

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… You can customize the color scheme in the Output Window – #196

On the Tools – Options – Environment – Fonts and Colors page, in the Show Settings For combo box, there’s an option for Output Window.

When selected, you’ll be able to customize the standard plain, selected, and inactive selection text options colors, but additionally, you can customize the color of the current list location.

Fonts and Colors options for Output Window

For me, personally, the dark blue has always been a bit distracting for me because it makes me think that the focus is always in the Output Window when it really is in the editor.  So, let’s tweak a bit.

By setting the Item background to Gray, we see the follow change. 

Gray currently selected line in output window

And i feel better knowing the focus isn’t always in the output window.

Technorati Tags: VS2005Tip,VS2008Tip