---
title: "Visual Studio 2008 每日提示(四)"
author: "cjc"
date: "2008-12-09T02:49:00Z"
tags: []
slug: "visual-studio-2008"
draft: false
lastmod: "2008-12-09T02:49:00Z"
id: 402684
url: "https://cjc.iteye.com/blog/402684"
---

&lt;script&gt;function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}&lt;/script&gt;

本篇包括tip31-tip30  
[http://www.watch-life.net/visual-studio/visual-studio-2008-tip-day-4.html](http://www.watch-life.net/visual-studio/visual-studio-2008-tip-day-4.html)

## #031、 把编辑器的背景变成黑色

原文地址:[http://blogs.msdn.com/saraford/archive/2007/09/06/did-you-know-how-to-change-the-editor-background-to-black.aspx](http://blogs.msdn.com/saraford/archive/2007/09/06/did-you-know-how-to-change-the-editor-background-to-black.aspx)

**操作步骤：**  
菜单：**工具+选项+环境+字体和颜色**，在”**显示项**“选项中选择”**纯文本**“，你可以修改”**项前景色**“来为白色，修改”**项背景色**“来为黑色

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Did.Howtochangetheeditorbackgroundtoblac_B5AB/EditorBackgroundToBlack_thumb.jpg)

评论：虽然背景是黑色比较酷，不过我不习惯，感觉比白色背景还费眼睛

## #032、 用Ctrl+Shift+W选中当前单词

原文地址：[http://blogs.msdn.com/saraford/archive/2007/09/07/did-you-know-ctrl-w-selects-the-current-word.aspx](http://blogs.msdn.com/saraford/archive/2007/09/07/did-you-know-ctrl-w-selects-the-current-word.aspx)

**操作步骤：**  
光标停在单词任意位置，按**Ctrl+Shift+W**就可以选中全部单词，无论光标位于单词最前面还是最后。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouknow.CtrlWselectsthecurrentword_F6BF/CtrlWSelectsCurrentWord_thumb.jpg)

评论：原文是使用Ctrl+W，我在vs2008 sp1 发现只有Ctrl+Shift+W才可以

## #033、 把代码拖拽到新的位置

原文地址：[http://blogs.msdn.com/saraford/archive/2007/09/10/did-you-know-you-can-select-code-with-the-mouse-and-drag-to-a-new-location.aspx](http://blogs.msdn.com/saraford/archive/2007/09/10/did-you-know-you-can-select-code-with-the-mouse-and-drag-to-a-new-location.aspx)

**操作步骤：**  
左键选中需要拖拽的代码，然后按住左键把代码拖拽到新的位置，如果你想复制的话，同时按“**Shift**”进行拖拽。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Did.youcanselectcodewiththemouseanddragt_BAAC/DraggingCode_thumb.jpg)

你可以在不同的选项卡文档之间拖转粘贴代码。  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Did.youcanselectcodewiththemouseanddragt_BAAC/DraggingCode2_thumb_2.jpg)

评论：这种拖拽是不是很方便？

## #034、 剪切和粘贴折叠代码

原文地址：[http://blogs.msdn.com/saraford/archive/2007/09/07/did-you-know-ctrl-w-selects-the-current-word.aspx](http://blogs.msdn.com/saraford/archive/2007/09/07/did-you-know-ctrl-w-selects-the-current-word.aspx)

**操作步骤：**  
可以直接选中折叠的代码，然后剪切，粘贴，整个折叠代码粘贴新的位置。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Did.youcancutandpasteacollapsedblockofco_C267/CutAndPasteCollapsedCode1_thumb_1.jpg)

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Did.youcancutandpasteacollapsedblockofco_C267/CutAndPasteCollapsedCode2_thumb.jpg)

评论：这样就避免了选中一大段的代码进行复制或剪切、粘贴操作

## #035、 折叠和展开代码

原文地址：[http://blogs.msdn.com/saraford/archive/2007/09/12/did-you-know-how-to-collapse-and-expand-code.aspx](http://blogs.msdn.com/saraford/archive/2007/09/12/did-you-know-how-to-collapse-and-expand-code.aspx)

**操作步骤：**  
1、切换大纲显示展开  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouknow.howtocollapseandexpandcode_CF96/ToggleOutliningExpansion_thumb_1.jpg)

在代码块的任意位置，按“**Ctrl+m,Ctrl+m**” ,可以折叠或展开光标所在代码块。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouknow.howtocollapseandexpandcode_CF96/ToggleOutliningExpansionExample_thumb.jpg)

2、切换所有大纲显示

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouknow.howtocollapseandexpandcode_CF96/ToggleAllOutlining_thumb.jpg)

按“**Ctrl+M, Ctrl+L** ”实现整个文档的折叠或展开

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouknow.howtocollapseandexpandcode_CF96/ToggleAllOutliningExample_thumb.jpg)

3、停止大纲显示

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouknow.howtocollapseandexpandcode_CF96/StopOutlining_thumb.jpg)

在编辑器的任意位置，按"**Ctrl+M, Ctrl+P**",则会停止大纲显示。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouknow.howtocollapseandexpandcode_CF96/StopOutliningExample_thumb.jpg)

4、启动自动大纲显示

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouknow.howtocollapseandexpandcode_CF96/StartAutomaticOutlining_thumb.jpg)

在上面的“停止大纲显示”并不是一个切换的快捷方式，不能用同样的快捷命令来启动大纲显示，只能通过菜单：  
**编辑+大纲显示+启动自动大纲显示**，来实现。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouknow.howtocollapseandexpandcode_CF96/StartAutomaticOutliningExample_thumb.jpg)

5、折叠到定义

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouknow.howtocollapseandexpandcode_CF96/CollapseToDefintions_thumb.jpg)

按“**Ctrl+M, Ctrl+O**”。把代码段按定义的格式进行折叠，让你快速浏览所有的方法。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouknow.howtocollapseandexpandcode_CF96/CollapseToDefintionsExample_thumb.jpg)

评论：最喜欢最有一个，难怪作者也说这个最有用了。快速的浏览所有代码的方法真方便

## #036、 隐藏大纲标记，但仍可以大纲显示

原文地址：[http://blogs.msdn.com/saraford/archive/2007/09/13/did-you-know-you-can-hide-outlining-selection-margin-without-turning-off-outlining.aspx](http://blogs.msdn.com/saraford/archive/2007/09/13/did-you-know-you-can-hide-outlining-selection-margin-without-turning-off-outlining.aspx)

**操作步骤：**  
菜单：**工具+选项+文本编辑器+常规**“，其中不选中”**选中内容的边距**“项。这样，大纲的标记没有了，但文档仍然可以按大纲的方式显示。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Did.youcanhideoutliningselectionmarginwi_D236/HideSelectionMargin_thumb.jpg)

评论：我觉得这个功能有些多余，既然选择了大纲方式，为什么要把大纲的标记去掉呢？

## #037、 如何显示窗口对话框中的水平平铺和垂直平铺的按钮

原文地址:[http://blogs.msdn.com/saraford/archive/2007/09/13/pop-quiz-how-do-you-show-the-tile-horizontally-and-tile-vertically-buttons-in-the-windows-windows-dialog.aspx](http://blogs.msdn.com/saraford/archive/2007/09/13/pop-quiz-how-do-you-show-the-tile-horizontally-and-tile-vertically-buttons-in-the-windows-windows-dialog.aspx)

**操作步骤：**  
菜单：工**具+选项+环境+常规**“，其中”**窗口布局**“项中选中”**多文档**“。这是在”**窗口**“对话框（调用菜单：**窗口+窗口. . .**）中，选中两个或两个以上的文档，”水平平铺和垂直平铺的按钮“就可用了。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/POPQUIZHowdoyoushowtheTileHorizontallyan_7735/WindowsWindowsTileButtons_thumb_1.jpg)

评论：很少用多文档的方式来浏览，作者这个tip有些不是很实用？

## #038、 隐藏水平或垂直滚动条

原文地址：[http://blogs.msdn.com/saraford/archive/2007/09/14/did-you-know-you-can-hide-the-vertical-and-horizontal-scrollbars-in-the-editor.aspx](http://blogs.msdn.com/saraford/archive/2007/09/14/did-you-know-you-can-hide-the-vertical-and-horizontal-scrollbars-in-the-editor.aspx)

**操作步骤：**  
菜单：**工具+选项+文本编辑器+常规**“，其中不选中”**水平滚动条**“项和”**垂直滚动条**“项。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Did.youcanhidetheverticalandhorizontalsc_D4B7/HideScrollbar_thumb.jpg)

虽然看不见滚动条，但你仍然可以滚动操作。

评论：这个功能让人费解，为啥要隐藏呢，也许有人不喜欢鼠标，要那个拖动的滚动条也没用不如隐藏。

## #039、 按鼠标滚轮(文档)可以上下左右滚动

原文地址：[http://blogs.msdn.com/saraford/archive/2007/09/17/did-you-know-pressing-the-mouse-wheel-allows-for-scrolling-in-all-directions.aspx](http://blogs.msdn.com/saraford/archive/2007/09/17/did-you-know-pressing-the-mouse-wheel-allows-for-scrolling-in-all-directions.aspx)

**操作步骤：**  
这没什么好说了，按鼠标滚轮后，出现上下左右滚动的标记后，上下左右移动鼠标，可以使文档上下左右滚动。按左键或右键解除。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Did.Pressingthemousewheelallowsforscroll_D9FB/thirdMouseButtonScrolling_thumb.jpg)

评论：这个功能没有什么新鲜之处，不过只支持后台的代码比如c#

## #040、 不用跳转行的对话框来实现转到某行

原文地址:[http://blogs.msdn.com/saraford/archive/2007/09/18/did-you-know-how-to-do-a-ctrl-g-without-the-go-to-line-dialog-box-popping-up.aspx](http://blogs.msdn.com/saraford/archive/2007/09/18/did-you-know-how-to-do-a-ctrl-g-without-the-go-to-line-dialog-box-popping-up.aspx)

**操作步骤：**  
1、按”**Ctrl+D**“，光标跳转到”查找组合框“  
2、输入行号。  
3、按”**Ctrl+G**“（不是回车，否者你就是查找输入数字了）。

另外，你可以通过双击行、列、字符区域可以弹出”转到行“的对话框（当然也可以用快捷键”**Ctrl+G**“）

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Did.HowtodoaCtrlGwithouttheGotolinedialo_FE45/GoToLineDialog2_thumb.jpg)

评论：我倒是觉得没有”Ctrl+G“调用对话框来的方便

更多文章见：[守望轩](http://www.watch-life.net/)\[[http://www.watch-life.net/](http://www.watch-life.net/)]