你最喜欢的Visual Studio快捷键是什么?我总是把我的手放在键盘上,远离鼠标!

请回答一个问题。


当前回答

一个我经常使用但很少有人使用的方法是:

Shift + Alt + F10然后回车

如果你输入一个类名,如Collection<string>,并且没有正确的名称空间导入,那么这个快捷组合将自动插入导入(而斜线符号紧跟在'>'之后)。

更新:

从这个答案的评论中有一个等效的快捷方式(感谢asterite!):

按下Ctrl +。

比我最初推荐的舒服多了。

其他回答

我已经映射了File。关闭CTRL+SHIFT+W。这和CTRL+TAB意味着你可以关闭任何你想要的文件。

概述

ctrl+M, ctrl+M -折叠/展开当前元素 ctrl+M, ctrl+O -折叠所有(例如,让您对复杂类有一个很好的概述) ctrl+M, ctrl+O -切换全部

这既适用于VB/ c#代码(例如折叠/展开一个函数),也适用于aspx页面(例如折叠/展开一个GridView定义)。

它的一个很好的用途是剪切或复制一大块标记或代码:例如,移动一个大的、扩展的<table>或<asp:gridview>定义:

到第一行去 ctrl+M, ctrl+M折叠 ctrl+X剪切它(你不需要选择它,只要你的插入点仍然在那一行) 移动到你想要的位置,并按ctrl+V粘贴。

F9:切换和取消切换断点!

Ctrl+M, Ctrl+O:缩回定义。我一直将它与#regions一起使用(不管Jeff怎么说),以获得屏幕上代码的概述。

格式的文档

   Ctrl+K, Ctrl+D

On an aspx page, this takes care of properly indenting all of your markup and ensures that everything is XHTML compliant (adds quotes to attributes, corrects capitalization, closes self-closing tags). I find that this makes it much easier to find mismatched tags and to make sure that my markup makes sense. If you don't like how it's indenting, you can control which tags go on their own line and how much space they get around them under Tools/Options/Text Editor/HTML/Format/Tag Specific Options. In your C# or VB code, this will correct any capitalization or formatting issues that didn't get caught automatically. For CSS files, you can choose compact (one definition per line), semi-expanded, or expanded (each rule on its own line); and you can choose how it handles capitalization.