visual-studio Visual Studio 命令窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1557371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio Command Window
提问by Kane
What is the usefulness of the Command Window in Visual Studio (menu View-> Other Windows-> Command Window)?
Visual Studio 中的命令行窗口(菜单View-> Other Windows-> Command Window)有什么用处?
I know that the Visual Studio Command Windowis used to execute commands or aliases directly in the IDE. The MSDN article Command Windowexplains how one can use the command window to print debug statements, but I feel that these can be easier executed in the Immediate Window.
我知道 Visual Studio命令窗口用于直接在 IDE 中执行命令或别名。MSDN 文章命令窗口解释了如何使用命令窗口打印调试语句,但我觉得在立即窗口中执行这些更容易。
What is the Command Window for?
命令窗口有什么用?
采纳答案by Ahmad Mageed
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.
Immediate 窗口主要用于调试、变量求值等。您对它很熟悉,所以我就不赘述它的用法了。有关它的更多信息,请查看 MSDN 文章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.
命令窗口允许您使用别名执行各种命令。您会注意到命令窗口提示符有一个>字符。您可以使用of Class1.cs,在您的解决方案中打开一个文件,按回车键,然后打开它。在“查找”对话框和“立即”窗口中,您需要包含 >,使其成为>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:
例如,要打开 Quick Watch 窗口,请??在命令窗口中键入。在立即窗口中尝试,你会得到:
??
Invalid expression term '?'
Type >??in the Immediate window, and it'll work.
键入>??在立即窗口,它会工作。
回答by Limited Atonement
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.
命令行窗口提供了与 IDE 的命令提示符样式交互,有些人似乎喜欢这种交互方式,但所有功能都可以通过快捷键访问,因此键入命令会不必要地缓慢。
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.
例如,“of”、“open”或“File.OpenFile”命令可能相当于导航到解决方案资源管理器(“CTRL+Tab”和箭头,或解决方案资源管理器的快捷方式之一“CTRL+ W、S"、"CTRL+ALT+L" 或您创建的另一个),然后键入所需文件的名称。解决方案资源管理器将在您键入时选择文件,当您找到正确的文件时按 Enter。
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.
通过在解决方案资源管理器中选择正确的项目并按“Alt、P、R”,可以快速添加引用(在这里不要按 CTRL+Tab,因为 VS 会搜索所有 com 组件的注册表,使用 CTRL+ SHIFT+Tab!)。添加新的代码文件类似:“Alt,P,W,'code',”。Visual Studio 中的菜单系统经过深思熟虑。使用 alt 绕过它非常有效,并且胜过命令行窗口。
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.
我目前使用命令窗口 (CTRL+Shift+C) 来“关闭所有”、“File.CloseAllButThis”和“打开”。当我第一次知道命令行窗口的存在时,我对它寄予厚望。我想我基本上是在寻找 VIM,但不要期望太多,特别是如果你不介意使用 Find 和其他命令的快捷键。
回答by Payam Buroumand
in VS 2017 or 2015 use alt + space shortcut key to appear command line window in current path of your project
在 VS 2017 或 2015 中使用 alt + 空格快捷键在项目的当前路径中显示命令行窗口

