Visual Studio 2019您应该知道的五个生产力技巧

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
CTRL+T objects quick find example for searching an interface and a variable
CTRL + T对象快速查找示例,用于搜索接口和变量

转到定义/转到实现/转到基础 (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
Contextual menu to run these tools
运行这些工具的上下文菜单

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
Go to definition behaviour
转到行为定义

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和两个派生类: SomethingConcreteAnotherConcreteClass

Image for post
Go to implementation behaviour
转到实施行为

With Go to Base you could do the reverse: starting from a derived class and reach its parent class.

使用转到基础,您可以做相反的事情:从派生类开始并到达其父类。

Image for post
Go to Base behaviour
转到基本行为

与活动文档同步 (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
Sync with Active Document icon
与活动文档同步图标

And the folder hierarchy will update focusing on your opened code document.

文件夹层次结构将更新,重点放在您打开的代码文档上。

Image for post
Sync with Active Document example
与Active Document同步示例

剪贴板历史 (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
Visual Studio Clipboard history example
Visual Studio剪贴板历史记录示例

多行编辑 (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
Multiple lines selection in action
多行选择行动

查看空格和制表符 (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
View White Space tool
查看空白工具

And that’s the result:

结果就是:

Image for post
Before and after
之前和之后

格式化文件 (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
Format document tool section
格式化文档工具部分

For example:

例如:

Image for post
Format document in action
格式化文档

按范围折叠代码部分 (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
An example of collpasing by scope
范围合并的示例

翻译自: https://medium.com/dev-genius/visual-studio-2019-five-productivity-tricks-you-should-know-d6a849d82c69

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值