Everyday programming needs agility. These are the tricks I use every single day to be more productive. And they work!
日常编程需要敏捷性 。 这些是我每天用来提高生产力的技巧 。 他们工作!
全文对象搜索 (Full text object search)
You remember just a class name, but you don’t want to search for it in the Solution Explorer. Or you just remember a variable name, and you want to go to its class istantly! Just type CTRL+T
and write its name!
您只记得一个类名,但不想在解决方案资源管理器中搜索它。 或者,您只记得一个变量名,并且想立即进入它的类! 只需键入CTRL+T
并输入其名称即可!
![Image for post](https://miro.medium.com/freeze/max/9999/1*4MZpOK8z6lwZX7mFrfvoWQ.gif)
转到定义/转到实现/转到基础 (Go to definition / Go to implementation / Go to base)
A very basic tool, but probably the most effective at all to boost your productivity: the tool to help you navigating to the right class or interface within your code. Simply right click on a class or an interface and you could go on with Go to definition or Go to implementation.
一个非常基本的工具,但却可能是最有效的提高生产力的工具:该工具可帮助您导航到代码中正确的类或接口。 只需右键单击一个类或接口,您就可以继续执行“ 转到定义”或“ 转到实现” 。
![Image for post](https://miro.medium.com/max/9999/1*nFdeMroUoZyoR6uVoIfRdg.png)
With Go to definition you can reach istantly a variable definition (useful for vertical codebases) or a class or interface definition. Visual Studio will open for you the right code document:
使用转到定义,您可以远距离到达变量定义(对垂直代码库有用)或类或接口定义。 Visual Studio将为您打开正确的代码文档:
![Image for post](https://miro.medium.com/freeze/max/9999/1*LA-CgZEqoe2Y00Xsuc5csw.gif)
With Go to implementation you can start from an abstraction and go to every implementation of it. In the following example I have an abstraction IAbstraction
, and two derived classes: SomethingConcrete
and AnotherConcreteClass
:
使用转到实现,您可以从抽象开始,然后进行抽象的每个实现。 在下面的示例中,我有一个抽象IAbstraction
和两个派生类: SomethingConcrete
和AnotherConcreteClass
:
![Image for post](https://miro.medium.com/freeze/max/9999/1*2K2-TGYgsD4t4bfrrC62lQ.gif)
With Go to Base you could do the reverse: starting from a derived class and reach its parent class.
使用转到基础,您可以做相反的事情:从派生类开始并到达其父类。
![Image for post](https://miro.medium.com/freeze/max/9999/1*qGEYwto1jZ1RylIxpM3tdA.gif)
与活动文档同步 (Sync with Active Document)
You have a very complex solution and you usually open a lot of tabs. Maybe you have done a lot of times “Go to definition” or “Go to implementation” and after navigating your code, you don’t know where you are in the folders hierarchy. Sync with Active Document is your compass. When are focusing a class, simply click its icon in Solution Explorer:
您的解决方案非常复杂,通常会打开很多标签。 也许您已经做了很多次“转到定义”或“转到实现”,并且在浏览代码之后,您不知道自己在文件夹层次结构中的位置。 与Active Document同步是您的指南针。 在关注课程时,只需在解决方案资源管理器中单击其图标:
![Image for post](https://miro.medium.com/max/9999/1*j5_gBLL3E5KZvy2KvQ3cAQ.png)
And the folder hierarchy will update focusing on your opened code document.
文件夹层次结构将更新,重点放在您打开的代码文档上。
![Image for post](https://miro.medium.com/freeze/max/9999/1*-YQWpB3X0Y6eFqyQ3aGxeA.gif)
剪贴板历史 (Clipboard history)
How many times you copy and pasted over another clipboard object and you’d like to recover it? Visual Studio implements a clipboad history! Just type CTRL+SHIFT+V
!
您复制并粘贴了另一个剪贴板对象多少次后又想恢复它? Visual Studio实现了剪贴板历史记录! 只需按CTRL+SHIFT+V
!
![Image for post](https://miro.medium.com/freeze/max/9999/1*Ng7Oruhr4pspjDDWDDRDFg.gif)
多行编辑 (Multiple lines edit)
This is a real productivity hack: select multiple lines and edit them at the same time. Just hold CTRL+ALT+SHIFT
while selecting your code on multiple lines with the arrow keys.
这是一个真正的提高生产力的技巧:选择多行并同时进行编辑。 只需按住 CTRL+ALT+SHIFT
同时用箭头键在多行中选择代码。
![Image for post](https://miro.medium.com/freeze/max/9999/1*4OHIIdofx-lPIELf-x4ufQ.gif)
查看空格和制表符 (View whitespaces and tabs)
This is for indentation maniacs (like me). With this command you can see dots where there are spaces and arrows where there are tabs. To enable it just go to Edit
, Advanced
, View White Space
.
这是用于压痕躁狂症 (像我一样)。 使用此命令,您可以看到有空格的 点和有制表符的 箭头 。 要启用它,只需转到“ Edit
,“ Advanced
,“ View White Space
。
![Image for post](https://miro.medium.com/max/9999/1*SQuJixbJlGf2M9ZziZK8PQ.png)
And that’s the result:
结果就是:
![Image for post](https://miro.medium.com/max/9999/1*MjAkuWL4IkLzU4d162sxNA.png)
格式化文件 (Format document)
Also known as: I code very quickly so I need help to make everything more beautiful. The auto formatter saves my life. With just a click it beautifies istantly my code page:
也称为:我编写代码非常快,因此我需要帮助使所有内容更加美观。 自动格式化程序可以挽救我的生命。 只需单击一下,它就可以美化我的代码页:
![Image for post](https://miro.medium.com/max/9999/1*VqhxdoOy-RHOv27qJZq-Xw.png)
For example:
例如:
![Image for post](https://miro.medium.com/freeze/max/9999/1*iU_CaJITpZNx7_gglUyhdg.gif)
按范围折叠代码部分 (Collapse code sections by scope)
Your pointer is in a large scope, maybe a method or in a large if condition, and you want to collapse it without using the mouse: CTRL+M, M
to collapse an open scope, CTRL+M, M
to expand a collapsed scope.
您的指针处于较大的范围内,可能是一个方法,或者处于较大的if条件下,并且您希望不使用鼠标就将其折叠: CTRL+M, M
来折叠打开的范围, CTRL+M, M
来展开折叠的范围。
![Image for post](https://miro.medium.com/freeze/max/9999/1*dM8Mw-3Rbr3rUxpbq0dK8w.gif)