“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’
Sara Ford’s Blog
Sara AsideShe had to do a little research to remember what this feature is called. She remembers calling this feature the “command line” in her test cases. But, after some internal debates, she was told it is really just the Find combo box running commands. Regardless of what the feature is called, you can run Visual Studio commands without having to open the Command Window. |
Press Ctrl+/ to reach the Find combo box; the “>” will be inserted for you. Of course, you could press Ctrl+D and then type > if you really wanted to.
It’s like Microsoft IntelliSense, but for Visual Studio commands instead.
Note that you may need to use a different keyboard shortcut, depending on which environment settings you are using. If Ctrl+/ does not work for you, go to Tools–Options–Environment–Keyboard to see what keyboard shortcut the Tools.GoToCommandLine command is bound to.
Happy Programming! =)
Tip 6.16: How to have fun with the Find combo box
“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’
Sara Ford’s Blog
Sara AsideShe learned from her test cases that you can run commands via the Find combo box. But, when she found Shawn Farkas’s blog (http://blogs.msdn.com/shawnfa), it took what she knew about the Find combo box to a whole new level. |
Following are some examples of commands you can run from the Find combo box, but the idea is that many Visual Studio commands take parameters that you can enter into the Find combo box. Hit the keyboard shortcut to a Visual Studio command, and the command will pull its parameters from the Find combo box.
Press Ctrl+D to go to the Find combo box. Now here are a few ways you can have some fun:
- Go to a line Type the line number, and press Ctrl+G. She likes showing this off as how you can do a “go to line” without popping up the Go To dialog box.
- Go to a file Type the name of the file (either in your project or on the INCLUDE path), and press Ctrl+Shift+G.
- Get help Type the keyword, and press F1.
You can also use command aliases, as shown here:
- To get a call stack, type >kb.
- To go to a Web page, type >nav http://www.codeplex.com.
You can read Shawn’s full blog post at http://blogs.msdn.com/shawnfa/archive/2004/02/27/81338.aspx.
Happy Programming! =)
“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’
Sara Ford’s Blog
To finish the customization of the external tools, you can check Prompt For Arguments if you need to enter or edit values each time you run the tool.
So now, if she needs to specify which file she wants Notepad to open, she’s prompted for the file name, which is the argument for notepad.exe.
And recall that you can set the Initial Directory, where Notepad is going to look for files.
Happy Programming! =)
Tip 6.14: How the external tools tokens work
“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’
Sara Ford’s Blog
She has hinted at a few of the external tool tokens, but let’s explore a little more. Most of these are self-explanatory and are explored in depth in the documentation, but here she’ll give us a high-level overview. You can view the documentation at http://msdn.microsoft.com/en-us/library/ekbzk5f8.aspx.
All Item and Current tokens that are available for the Arguments edit box operate on the currently active editor. Note the editor does not need to have focus to be able to work, but it must at least have inactive selection.
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 the Binary Directory option is new for Visual Studio 2008.
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.
Happy Programming! =)
“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’
Sara Ford’s Blog
At the bottom of the External Tools dialog box, you’ll see more options for customizing the external tool within the IDE. This 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 the IDE.
Using the command prompt as the tool, you can set Arguments to something like /C echo $(CurText), which signifies the following:
- /C, from cmd.exe, carries out the command specified by the string and then terminates.
- $(CurText) is a token that comes from Visual Studio that represents the currently selected text, displayed as Current Text in the menu.
Now, when running this external tool with a line of text selected in the editor, the Output window displays the text.
Happy Programming! =)
“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’
Sara Ford’s Blog
Continuing with the newly added Notepad tool from the previous tip, you can use the External Tools dialog box to sort your list of external tools as they will appear on the Tools menu. To the right of the Menu Contents list, you’ll find the Move Up and Move Down buttons.
You can specify a mnemonic, also known as a keyboard accelerator, by putting an ampersand in front of the letter to be used as the accelerator in the Title field.
Now, on the Tools menu, you can simply press m to launch Notepad.
If there’s a mnemonic conflict, the focus cycles among the commands that share that mnemonic. Then you press Enter at the appropriate command to execute the command. It is ideal to have no conflicts.
Happy Programming! =)
“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’
Sara Ford’s Blog
For this tip, let’s add Notepad as an external tool.
Go to the Tools–External Tools dialog box, and you’ll see the Add button. Click Add to create a [New Tools 1] placeholder. Rename the title by typing Notepad.
For the Command edit box, use the name of the actual executable. You should be able to just type notepad.exe, depending on your environment variables.
This is the minimum amount of information you need to include to make an external tool work. But let’s go a little further by exploring the optional arguments.
For Arguments, you can type the name of a file, either an existing file if you want Notepad to open it or the name of a file if you want Notepad to create.
For Initial Directory, you can type the file path, either the path where the file exists or where you want Notepad to create it.
And of course, you’ll see Notepad now in the Tools menu.
We’ll explore more of the arguments and other options in the upcoming tips.
Happy Programming! =)
Tip 6.10: You can run external tools from the IDE
“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’
Sara Ford’s Blog
Sara AsideOkay she has to admit, she’s not the local expert in External Tools. She can talk about the functionality all day long, but nothing is better than real-world examples. When she blogged about this tip, she asked blog readers to leave comments about how they use this feature. You can see their comments at http://blogs.msdn.com/b/saraford/archive/2008/04/24/did-you-know-you-can-run-external-tools-within-visual-studio-201.aspx. |
Let’s start with the basics. Go to Tools–External Tools to bring up the External Tools dialog box. You’ll notice a set of built-in tools ready to go for you.
This list of tools under Menu Contents maps directly to the list presented on the Tools menu, as shown here:
Sara AsideThe first time she made this connection she was totally taken aback. She probably saw this list of tools for years, but she never knew it came directly from the External Tools dialog box. |
Happy Programming! =)
Tip 6.9: You can use team settings to keep Visual Studio settings on different machines in sync
“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’
Sara Ford’s Blog
Under Tools–Options–Environment–Import And Export Settings, you’ll see an option called Use Team Settings File.
This option enables you to let all the members of your team use the same baseline settings. You can provide a .vssettings file (by creating these customizations on your machine and then using Tools–Import And Export Settings–Export to create the file). Then put the .vssettings file on a Universal Naming Convention (UNC) share. Next, you check the Use Team Settings File check box, pointing it at this file.
So, what happens now? Whenever Visual Studio launches, it’ll check the time stamp of the .vssettings file, and if there has been an update, Visual Studio will reapply all the settings from the .vssettings file. But be aware, if you have any custom changes, they will be overwritten when Visual Studio detects the new team settings file.
She thinks that this works really well in a scenario where there’s a single developer who works on multiple computers, because any tweaks the developer makes on one machine will be carried over to the next machine.
Happy Programming! =)
Tip 6.8: You can copy the full file path from the final wizard page when exporting settings
“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’
Sara Ford’s Blog
This tip is more like a “tip” than her usual “micro functionality” daily tips. After you export, the final page of the wizard shows you the full file path. This page is just a read-only edit box that can take focus. In other words, you can put your cursor in it and copy the full file path.
After you export your settings, you may want to open the file and see what’s there, in case you want to make any tweaks. Otherwise, you’ll have to open the Import And Export Settings dialog box and go through the wizard to guess where you exported that file to.
Happy Programming! =)
















