---
title: "Visual Studio 2008 每日提示(三)"
author: "cjc"
date: "2008-12-05T11:52:00Z"
tags: []
slug: "visual-studio-2008"
draft: false
lastmod: "2008-12-05T11:52:00Z"
id: 402686
url: "https://cjc.iteye.com/blog/402686"
---

&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;

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

## #021、 调整字符、词或行的顺序

原文地址:[http://blogs.msdn.com/saraford/archive/2007/08/23/did-you-know-how-to-transpose-characters-words-and-lines-in-the-editor.aspx](http://blogs.msdn.com/saraford/archive/2007/08/23/did-you-know-how-to-transpose-characters-words-and-lines-in-the-editor.aspx)

**操作步骤：**  
1.调整字符的顺序:**Ctrl+T**.  
2.调整词的顺序:**Ctrl+Shift+T**.  
3.调整行的顺序:**Alt+Shift+T**.

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

如上例所示（在“now is the time”这句话里，光标位于“is”前面）  
1、按**Ctrl+T**，“i”和“s”调换了位置,变成：nowi s the time 。  
2、按**Ctrl+Shift+T**，“is”和“the”调换了位置,变成：nowi s the time 。  
3、按**Alt+Shift+T**交换当前行与下一行的位置。

评论：我觉得第三个有用一些，不然记得快捷键就太多了

## #022、 删除一行开头的水平空白字符

原文地址:[http://blogs.msdn.com/saraford/archive/2007/08/24/did-you-know-how-to-delete-horizontal-white-space-at-the-beginning-of-a-line.aspx](http://blogs.msdn.com/saraford/archive/2007/08/24/did-you-know-how-to-delete-horizontal-white-space-at-the-beginning-of-a-line.aspx)

**操作步骤：**  
1、菜单：**编辑+高级+删除水平空白**  
2、快捷键：**Ctrl+K, Ctrl+\\**

此功能同样适用多行的情况。

评论：因为我一般用“空格”来替代“Tab”制表符，所以我多用减小缩进：Shift+TAB

## #023、 如何跟踪编辑后的修改(修订)

原文地址：[http://blogs.msdn.com/saraford/archive/2007/08/27/did-you-know-there-s-a-way-to-track-changes-in-the-editor.aspx](http://blogs.msdn.com/saraford/archive/2007/08/27/did-you-know-there-s-a-way-to-track-changes-in-the-editor.aspx)

**操作步骤：**

1、**黄色**：（上次保存后）你编辑的当前行，在保存前（在编辑器边缘）显示黄色（竖条）。保存后显示绿色（竖条）。  
2、**绿色**：保存后显示绿色（竖条）。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didy.Theresawaytotrackchangesintheeditor_10ACC/TrackingChanges_thumb.jpg)

启用设置方法，菜单：**工具+设置+文本编辑器+常规**，选中“**修订**”项，并同时选中“**选定内容的边距**”。

评论：以前我一直不知道还有这个功能，修改程序中，忘记了哪里改了，哪里没有改，有这个功能就方便了

## #024、 使用快捷键进行字符大小写转换

原文地址：[http://blogs.msdn.com/saraford/archive/2007/08/28/did-you-know-there-s-a-keyboard-shortcut-default-to-upper-and-lower-case-a-word-in-the-editor.aspx](http://blogs.msdn.com/saraford/archive/2007/08/28/did-you-know-there-s-a-keyboard-shortcut-default-to-upper-and-lower-case-a-word-in-the-editor.aspx)

**操作步骤：**

1、按**Ctrl+Shift+U** 将当前字符或选中的字符转换为大写  
2、按**Ctrl+U** 将当前字符或选中的字符转换为小写

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

当然，你可以通过菜单：**编辑+高级+转换为大写**（**转换为小写**）

评论：要是有转换首字母大写的快捷功能就好了，嘿嘿 ![smile](http://www.watch-life.net/wp-includes/images/smilies/icon_smile.gif)

## #025、 减少或增大行缩进

原文地址：[http://blogs.msdn.com/saraford/archive/2007/08/29/did-you-know-you-can-increase-and-decrease-the-line-indent-from-the-text-editor-toolbar.aspx](http://blogs.msdn.com/saraford/archive/2007/08/29/did-you-know-you-can-increase-and-decrease-the-line-indent-from-the-text-editor-toolbar.aspx)

**操作步骤：**  
针对选中的代码行  
1、增大缩进：**Tab**。  
2、减少缩进：**Shift+Tab**

或者菜单：**编辑+高级+增加行缩进** 或者 **编辑+高级+减少行缩进**

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

当然，你可以通过菜单：**编辑+高级+转换为大写**（**转换为小写**），也可以通过点击工具栏增大或减少缩进的图标按钮实现。

评论：我想说的是，如果我如果用菜单来操作的话，我都不好意思说你程序员。 ![smile](http://www.watch-life.net/wp-includes/images/smilies/icon_smile.gif)

## #026、 在编辑器中显示行号

原文地址：[http://blogs.msdn.com/saraford/archive/2007/08/30/did-you-know-how-to-show-line-numbers-in-the-editor.aspx](http://blogs.msdn.com/saraford/archive/2007/08/30/did-you-know-how-to-show-line-numbers-in-the-editor.aspx)

**操作步骤：**  
菜单：**工具+选项+文本编辑器+所有语言+常规**，选中“**显示**”中“行**号**”项。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyoukn.howtoshowlinenumbersintheeditor_D461/LineNumbers_thumb.jpg)

如果你只想特定的语言显示或不显示行号，可以这样设置：**工具+选项+文本编辑器+&lt;某个语言&gt;+常规**，自己来选择显示或不显示。这个设置会覆盖上面的全局设置。

评论：显示行号对于查找错误的代码行非常有用。

## #027、 打印行号

原文地址：[http://blogs.msdn.com/saraford/archive/2007/08/31/did-you-know-how-to-print-line-numbers.aspx](http://blogs.msdn.com/saraford/archive/2007/08/31/did-you-know-how-to-print-line-numbers.aspx)

**操作步骤：**  
菜单：**文件+打印**，看到下面两个选项  
1、**隐藏折叠区域**  
2、**包括行号**

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

对于第一的选项，你可以在打印的时候，把所有折叠的代码都隐藏，只打印需要的部分。那么，第二项就是在打印的时候，显示行号。

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

评论：只有代码编辑器里，存在折叠了区域,"**隐藏折叠区域**"才可以变为可用

## #028、 将自定义的字体和颜色应用到打印机

原文地址：[http://blogs.msdn.com/saraford/archive/2007/09/03/did-you-know-to-boldly-print-where-no-dev-has-printed-before.aspx](http://blogs.msdn.com/saraford/archive/2007/09/03/did-you-know-to-boldly-print-where-no-dev-has-printed-before.aspx)

**操作步骤：**  
菜单：**工具+选项+环境+字体和颜色**，在“**显示其设置**”的下拉框中选中“**打印机**”，单击右侧“**使用...**" 按钮，选择”**使用文本编辑器设置**“。

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

评论：这个在打印文档的时候很有用

## #029、 将文件的路径打印到页眉

原文地址：[http://blogs.msdn.com/saraford/archive/2007/09/04/did-you-know-how-to-print-the-file-path-as-the-page-header.aspx](http://blogs.msdn.com/saraford/archive/2007/09/04/did-you-know-how-to-print-the-file-path-as-the-page-header.aspx)

**操作步骤：**  
菜单：”文件+页面设置“，选中左下侧的”页眉“的选项。

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

打印后，页眉会显示文件的路径，如下图所示：

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

评论：这个在打印文档的时候也很有用

## #030、 改变书签的颜色

原文地址:[http://blogs.msdn.com/saraford/archive/2007/09/05/did-you-know-how-to-change-a-bookmark-color.aspx](http://blogs.msdn.com/saraford/archive/2007/09/05/did-you-know-how-to-change-a-bookmark-color.aspx)

**操作步骤：**  
菜单：**工具+选项+环境+字体和颜色**，在”**显示项**“选项中选择”**书签**“，你可以修改”项背景色“来改变书签的颜色。

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

如果你想让这个设置生效的话，不能启用”**文本编辑器**“的”**指示器边距**“选项，方法如下，菜单：**工具+选项+文本编辑器+常规**，在”**显示**“选项里不选中**指示器边距**“。如果启用了，就只会显示书签的图标，而图标的是无法改变颜色的。

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

评论：我觉得书签的作用就是为了查找，不必改变什么颜色，用书签图标来显示比较清爽

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