Visual Studio Command Window

2020-02-02 08:05发布

What is the usefulness of the Command Window in Visual Studio (menu View -> Other Windows -> Command Window)?

I know that the Visual Studio Command Window is used to execute commands or aliases directly in the IDE. The MSDN article Command Window explains how one can use the command window to print debug statements, but I feel that these can be easier executed in the Immediate Window.

What is the Command Window for?

3条回答
一夜七次
2楼-- · 2020-02-02 08:44

in VS 2017 or 2015 use alt + space shortcut key to appear command line window in current path of your project

查看更多
▲ chillily
3楼-- · 2020-02-02 08:50

The Immediate window is mostly used for debugging, variable evaluation, etc. You sound familiar with it, so I won't belabor its usage. For more information on it, check out the MSDN article Immediate Window.

The Command window allows you to execute a variety of commands using their aliases. You'll notice that the command window prompt has a > character. You can open a file in your solution using of Class1.cs, hit enter, and open it up. In the Find dialog and Immediate window you would need to include the >, making it >of Class1.cs.

Nonetheless, you can do exactly the same thing in the Immediate window by prefixing a command with > as well. The Command window saves you an extra keystroke and is ready to go whenever you drop a command alias.

Check out these links for some commands:

For example, to open the Quick Watch window, type ?? in the command window. Try that in the Immediate window and you'll get:

??
Invalid expression term '?'

Type >?? in the Immediate window, and it'll work.

查看更多
forever°为你锁心
4楼-- · 2020-02-02 08:54

The Command Window offers a command-prompt style interaction with the IDE which some people seem to like, but all of the functions can be reached by shortcut keys, making typing out the command unnecessarily slow.

The "of", "open", or "File.OpenFile" command, for instance, is probably equivalent to navigating to the Solution Explorer ("CTRL+Tab" and arrow around, or one of the shortcuts for Solution Explorer "CTRL+W, S", "CTRL+ALT+L", or another of your creation), then typing the name of the file you want. The Solution Explorer will select the file as you type, press enter when you get to the right file.

Adding references can be done quickly by selecting the correct project in the solution explorer and pressing "Alt,P,R" (Just don't hit CTRL+Tab here because then VS will scour the registry for all the com components, use CTRL+SHIFT+Tab!). Adding a new code file is similar: "Alt,P,W, 'code', ". The menu system in Visual Studio is very well thought out. Using alt to get around it is very efficient, and beats the Command Window.

I currently use the command window (CTRL+Shift+C) to "closeall", "File.CloseAllButThis", and "open". I had high hopes for the Command Window when I first learned of its existence. I think I was basically looking for VIM, but don't expect too much from it, especially if you don't mind using shortcut keys for Find and other commands.

查看更多
登录 后发表回答