工欲善其事,必先利其器——图文并茂详解VisualStudio使用技巧一
VisualStudio虽然大家每天都在使用它,但是可能有些功能的使用大家并不清楚,甚至不知道有这项功能,下面这些技巧可能会对你有所帮助。
先上目录:
第一节:
怎样给自己的代码添加代码段。
怎样使用任务管理器。
怎样使用发布网站功能。
怎样把常用代码放到工具箱中的常规选项中。
怎样怎样在多个窗口查看同一个文档。
怎样创建区域,方便代码阅读及维护?
怎样创建矩形选区?
1.怎样给代码添加版权信息。
写代码经常会要写一些版权信息、或者一些常用的命名空间引用,如果每个页面都拷贝粘贴一遍,确实挺麻烦的。有什么可以让我们一劳永逸的办法呢?vs中的模板功能来可以帮助我们达到这个目的。
解决办法:
示意图如下:


2

3

4

5

6

7

8

9


11

12

13

14

15

16

17

18

19

20


22

23

24

25


26

27


28

29


30

31




注意:WebSite模板和Web应用程序模板是不一样的。
2.怎样给代码添加代码段?
编码过程中,经常会有一些常用的代码结果会反复使用,有没有一种办法把这些代码嵌套到VS IDE中呢?
解决办法:完全没问题,使用
见图示:
代码如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17


18

19

20

21


22

23

24

25


26

27

28

29

30

31

32

33

使用:
如上图:找到自己设置的代码段的别名,输入回车键,然后输入tab键,即可自动生成如下代码:
3.怎样使用任务管理器?
VS中的任务管理器能够很好地解决这一问题,使用方法:在要标志的地方输入://TODO:内容,然后在视图--任务列表中打开所有的任务列表。
4.怎样使用发布网站功能?
在我们部署Web应用程序的时候,像.cs等文件因为已经生成了dll,对部署站点是没有什么用处的,这个时候一般都是手动去删除这些没用的文件,有没有更快捷的办法来完成这项工作呢?VS自带的发布功能能够很好地解决这一问题。
选中项目--右键属性--发布(Publish) 或者选择生成(Build)--发布(Publish)打开如下对话框:
5.怎样把备份常用代码,快捷方便下次使用?
在编码过程中我们会经常编写一些重复的代码,怎样把这些代码备份起来,下次使用的时候能够快捷地调用出来呢?
工具箱中的常用选项能够达到这个功能,把我们常用的代码拖放到工具箱中的常用选项卡中,下次使用的时候直接双击就行了。如下图:
6.怎样在同一个窗口中查看一个文档的不同部分?
直接见图:
拖动后下效果见下图:
看到了吗?一个文档被分成了两个!你可以在一个窗口中同时查看这个文档的头部和尾部。
怎样还原过去呢?直接拖动那个小条条,恢复原位就行了。
7.怎样创建区域,方便代码阅读及维护?
添加
#region
//代码区域
#endregion
8.怎样创建矩形选区?
有时候我们只想复制一段代码的前几列,后几列不想复制,怎样才能达到这种效果呢?
很简单,摁住alt键,然后拖动鼠标即可,效果如下: