Visual Studio 2008 每日提示(三十六)

时间:2022-04-29
本文章向大家介绍Visual Studio 2008 每日提示(三十六),主要内容包括# 361、按Ctrl+K, Ctrl+v在解决方案快速查找对象、#363 、为更好的调试体验把“调用堆栈”窗口停靠在解决方案管理器的旁边、#363 、在查找结果窗口自定义显示查找结果、#364 、Visual Studio配备供你的应用使用的图片库、#365 、在一个项目添加链接项、#366、 记录Visual Studio活动性故障的方法、#367 、在堆栈定位中转到定义、#368 、在解决方案浏览器中双击属性目录打开项目属性页、#369 、按Ctrl+PgUp 和 Ctrl+PgDn在项目属性标签间切换、#370 、列出所有 Visual Studio快捷键的宏、基本概念、基础应用、原理机制和需要注意的事项等,并结合实例形式分析了其使用技巧,希望通过本文能帮助到大家理解应用这部分内容。

# 361、按Ctrl+K, Ctrl+v在解决方案快速查找对象

原文链接: Ctrl+K, Ctrl+v allows you to quickly search for objects within your solution

操作步骤: 无论你在IDE的任何地方按Ctrl+K, Ctrl+v,焦点会跳转到类视图的搜索组合框,你可以开始输入和立即搜索。

评论:这个快捷键也许你用的不错,如果经常用类视图的话,可以考虑多用,对效率提高很有帮助。

#363 、为更好的调试体验把“调用堆栈”窗口停靠在解决方案管理器的旁边

原文链接:Dock your Call Stack window alongside the Solution Explorer for a better debugging experience

//www.watch-life.net/visual-studio/visual-studio-2008-tip-day-36.html

操作步骤: 每当我发现一个需要开发人员来研究我的机器的bug时候,我发誓我每次做的第一件事就是把“调用堆栈”窗口停靠在解决方案管理器的旁边。

评论:把“调用堆栈”窗口停靠在解决方案管理器的旁边,可以看见更多堆栈行,如果是默认放在下方的话,最多只能看到5行。

#363 、在查找结果窗口自定义显示查找结果

原文链接: You can customize how search results are displayed in the Find Results window

操作步骤: 在做文件查找的时候,比较恼火的是,Visual Studio会显示文件的整个目录,被迫使用滚动条才可以看见文件名和搜索结果. 可以通过修改注册表来修改显示的结果

1、打开注册表到HKCUSoftwareMicrosoftVisualStudio9.0Find 2、添加一个字符串值,名称为:Find result format 值为:$f$e($l,$c):$trn

参数所代表意义如下 $f 是文件名

$e 是扩展名

$l 是行

$c 列

$t 文本所在行

再次在结果窗体1查看查找结果

下面是全部有关参数说明列表

Files

$p path

$f filename

$v drive/unc share

$d dir

$n name

$e .ext

Location

$l line

$c col

$x end col if on first line, else end of first line

$L span end line

$C span end col

Text

$0 matched text

$t text of first line

$s summary of hit

$T text of spanned lines

Char

n newline

s space

t tab

\ slash

$ $

评论:这个自定义查看搜索结果的方法不错,值得试试。

#364 、Visual Studio配备供你的应用使用的图片库

原文链接:Visual Studio comes with an image library for you to use in your applications

操作步骤: 在Visual Studio的安装目录:Program FilesMicrosoft Visual Studio 9.0Common7VS2008ImageLibrary 有个 VS2008ImageLibrary.zip文件。这个zip文件里很多图片。

评论:这真是个意外的发现,不必到处找图了。

#365 、在一个项目添加链接项

原文链接:How to add a Linked Item to a project

操作步骤: 右键单击解决方案的一个项目,添加+现有项,你会发现在“添加”右侧有个下拉按钮,单击下拉按钮选择“添加为链接”。

在项目里可以看见一个链接项目,显示为快捷图标

评论:添加链接项,对于代码共享是非常有用。

#366、 记录Visual Studio活动性故障的方法

原文链接:There’s a way to have Visual Studio log its activity for troubleshooting

操作步骤: 有个内部命令:devenv.exe /log记录有关Visual Studio的活动日志。 如果没有收入文件名,日志将会被写入:%APPDATA%MicrosoftVisualStudio9.0ActivityLog.xml

评论:启动vs时启动活动日志,对于处理有关vs的故障很有帮助,特别想作者这样的测试人员。

#367 、在堆栈定位中转到定义

原文链接:There’s is a Go To Definition navigation stack

操作步骤: 如果已经转到定义,想返回此前的地方,你可以按CTRL+SHIFT+8

如果想再次返回定义,可以按CTRL+SHIFT+7.

评论:这个技巧是作者花了半个小时才找到的,很不错。可以在定义和引用质检来回跳转

#368 、在解决方案浏览器中双击属性目录打开项目属性页

原文链接:You can double-click on the properties folder in the Solution Explorer to open the project properties page

操作步骤: 如题,双击属性目录打开项目属性页

评论:呵呵,这个打开项目属性的方法隐藏得比较深吧。其实右键属性目录,选择“打开”也可以打开项目属性。

#369 、按Ctrl+PgUp 和 Ctrl+PgDn在项目属性标签间切换

原文链接:You can use Ctrl+PgUp and Ctrl+PgDn to switch among the project properties tags

操作步骤: 你可以通过Ctrl+PgUpCtrl+PgDn来浏览属性窗体,因为属性窗口服从Window.PreviousTab 和Window.NextTab命令

评论:我还是习惯用鼠标来导航。

#370 、列出所有 Visual Studio快捷键的宏

原文链接:There’s a macro for listing out all the keyboard shortcuts in Visual Studio

操作步骤: 宏的源代码如下:

 Imports System
 Imports EnvDTE
 Imports EnvDTE80
 Imports EnvDTE90
 Imports System.Diagnostics
 Public Module Module1
     Function GetOutputWindowPane(ByVal Name As String, Optional ByVal show As Boolean = True) As OutputWindowPane
         Dim window As Window
         Dim outputWindow As OutputWindow
         Dim outputWindowPane As OutputWindowPane
         window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
         If show Then window.Visible = True
         outputWindow = window.Object
         Try
             outputWindowPane = outputWindow.OutputWindowPanes.Item(Name)
         Catch e As System.Exception
             outputWindowPane = outputWindow.OutputWindowPanes.Add(Name)
         End Try
         outputWindowPane.Activate()
         Return outputWindowPane
     End Function
     Sub ListCommands()
         Dim outwin As OutputWindowPane = GetOutputWindowPane(“List Commands”, True)
         outwin.Clear()
         For Each cmd As Command In DTE.Commands
             Dim bindings() As Object
             bindings = cmd.Bindings
             For Each binding As String In bindings
                 outwin.OutputString(cmd.Name.ToString() + vbTab + binding + vbCrLf)
             Next
         Next
     End Sub
 End Module 

在宏编辑器里,把光标放在ListCommands()上,单击f5,将会在输出窗口看见所有vs的快捷键

评论:如果你想了解全部的vs快捷键,这个宏对你很有用。