3:'Copyright(c)2011YONG.Allrightsreserved.4:'5:'

亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Visual Studio 2010利用宏添加注釋

系統 1980 0

Visual Studio 2010 (下面簡稱 VS )編寫類的過程中通常會在類的前面寫上如下注釋:

        
             1:  
        
        
          '------------------------------------------------------------------------------
        
      
        
             2:  
        
        
          ' <copyright file="***.vb" company="YONG">
        
      
        
             3:  
        
        
          '     Copyright (c) 2011 YONG. All rights reserved.
        
      
        
             4:  
        
        
          ' <copyright>
        
      
        
             5:  
        
        
          ' <author>郗曉勇<author>
        
      
        
             6:  
        
        
          ' <author>博客地址http://blog.csdn.net/beijiguangyong<author>
        
      
        
             7:  
        
        
          ' <date>2011年4月29日<date>
        
      
        
             8:  
        
        
          ' <description>
        
      
        
             9:  
        
        
          '
        
      
        
            10:  
        
        
          '
        
      
        
            11:  
        
        
          '
        
      
        
            12:  
        
        
          '
        
      
        
            13:  
        
        
          ' <description>
        
      
        
            14:  
        
        
          '------------------------------------------------------------------------------
        
      

每次復制粘貼未免太麻煩,我們可以利用 VS 的宏來為我們自動添加如上注釋。具體操作如下:

1. 找到 VS IDE 宏編輯器

image

2. 打開后選擇添加 Model

image

3. 起一個自己喜歡的名字(這里以HeadFileNote為例)

image

4. 點擊添加后出現如下編輯界面

image <style type="text/css"> <!-- .csharpcode, .csharpcode pre {font-size:small; color:black; font-family:consolas,"Courier New",courier,monospace; background-color:#ffffff} .csharpcode pre {margin:0em} .csharpcode .rem {color:#008000} .csharpcode .kwrd {color:#0000ff} .csharpcode .str {color:#006080} .csharpcode .op {color:#0000c0} .csharpcode .preproc {color:#cc6633} .csharpcode .asp {background-color:#ffff00} .csharpcode .html {color:#800000} .csharpcode .attr {color:#ff0000} .csharpcode .alt {background-color:#f4f4f4; width:100%; margin:0em} .csharpcode .lnum {color:#606060} --> </style>

5. 在右側即可編輯自己所需要的“宏”了,我們將添加的“宏”代碼如下

        
             1:  
        
        
          Imports
        
         System
      
        
             2:  
        
        
          Imports
        
         EnvDTE
      
        
             3:  
        
        
          Imports
        
         EnvDTE80
      
        
             4:  
        
        
          Imports
        
         EnvDTE90
      
        
             5:  
        
        
          Imports
        
         EnvDTE90a
      
        
             6:  
        
        
          Imports
        
         EnvDTE100
      
        
             7:  
        
        
          Imports
        
         System.Diagnostics
      
        
             8:  
        
      
        
             9:  
        
        
          Public
        
        
          Module
        
         HeadFileNote
      
        
            10:  
        
        
          Sub
        
         DocumentFileHeader()
      
        
            11:  
        
        
          Dim
        
         doc 
        
          As
        
         Document
      
        
            12:  
        
        
          Dim
        
         docName 
        
          As
        
        
          String
        
      
        
            13:  
        
        
          Dim
        
         companyName 
        
          As
        
        
          String
        
         = 
        
          "YONG"
        
      
        
            14:  
        
        
          Dim
        
         authorName 
        
          As
        
        
          String
        
         = 
        
          "郗曉勇"
        
      
        
            15:  
        
        
          Dim
        
         authorContact 
        
          As
        
        
          String
        
         = 
        
          "我的博客地址http://blog.csdn.net/beijiguangyong"
        
      
        
            16:  
        
        
          Dim
        
         copyrightText 
        
          As
        
        
          String
        
         = 
        
          String
        
        .Format(
        
          "Copyright (c) {0} {1}. All rights reserved."
        
        , 
        
          Date
        
        .Now.Year, companyName)
      
        
            17:  
        
      
        
            18:  
        
        
          ' 從程序中獲得文件的名字
        
      
        
            19:  
        
                doc = DTE.ActiveDocument
      
        
            20:  
        
      
        
            21:  
        
        
          '獲得當前編輯類的名字
        
      
        
            22:  
        
                docName = doc.Name
      
        
            23:  
        
      
        
            24:  
        
        
          ' 將添加焦點定位在文件首部
        
      
        
            25:  
        
                DTE.ActiveDocument.Selection.StartOfDocument()
      
        
            26:  
        
      
        
            27:  
        
        
          ' 添加一個版權說明
        
      
        
            28:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "'------------------------------------------------------------------------------"
        
        
          '以String類型添加自己想要的符號、文字
        
      
        
            29:  
        
                DTE.ActiveDocument.Selection.NewLine() 
        
          '添加一個空行
        
      
        
            30:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "' <copyright file="
        
        
          ""
        
         + docName + 
        
          ""
        
        
          " company="
        
        
          ""
        
         + companyName + 
        
          ""
        
        
          ">"
        
      
        
            31:  
        
                DTE.ActiveDocument.Selection.NewLine()
      
        
            32:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "'     "
        
         + copyrightText
      
        
            33:  
        
                DTE.ActiveDocument.Selection.NewLine()
      
        
            34:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "' <copyright>"
        
      
        
            35:  
        
      
        
            36:  
        
        
          ' 添加用戶相關信息
        
      
        
            37:  
        
                DTE.ActiveDocument.Selection.NewLine()
      
        
            38:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "' <author>"
        
         + authorName + 
        
          "<author>"
        
      
        
            39:  
        
                DTE.ActiveDocument.Selection.NewLine()
      
        
            40:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "' <author>"
        
         + authorContact + 
        
          "</author>"
        
      
        
            41:  
        
                DTE.ActiveDocument.Selection.NewLine()
      
        
            42:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "' <date>"
        
         + 
        
          String
        
        .Format(
        
          "{0:D}"
        
        , 
        
          Date
        
        .Now) + 
        
          "<date>"
        
      
        
            43:  
        
                DTE.ActiveDocument.Selection.NewLine()
      
        
            44:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "' <description>"
        
      
        
            45:  
        
                DTE.ActiveDocument.Selection.NewLine()
      
        
            46:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "'"
        
      
        
            47:  
        
                DTE.ActiveDocument.Selection.NewLine()
      
        
            48:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "'"
        
      
        
            49:  
        
                DTE.ActiveDocument.Selection.NewLine()
      
        
            50:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "'"
        
      
        
            51:  
        
                DTE.ActiveDocument.Selection.NewLine()
      
        
            52:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "'"
        
      
        
            53:  
        
                DTE.ActiveDocument.Selection.NewLine()
      
        
            54:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "' <description>"
        
      
        
            55:  
        
                DTE.ActiveDocument.Selection.NewLine()
      
        
            56:  
        
                DTE.ActiveDocument.Selection.Text = 
        
          "'------------------------------------------------------------------------------"
        
      
        
            57:  
        
                DTE.ActiveDocument.Selection.NewLine()
      
        
            58:  
        
        
          End
        
        
          Sub
        
      
        
            59:  
        
        
          End
        
        
          Module
        
      

6. 添加完畢后點擊保存

image

這樣我們的“宏”就編好了,下面接著介紹怎樣定義快捷鍵為我們的類添加頭注釋。

7. 進入我們的 VS 開發環境打開選項,進行相關設置

image

8. 設置完成后單擊“ Assign ”(注冊快捷鍵)如圖

image

9. 單擊“ OK ”完成所有設置,現在就去按下快捷鍵試試自己編輯的“注釋添加宏”吧。

image <style type="text/css"> <!-- .csharpcode, .csharpcode pre {font-size:small; color:black; font-family:consolas,"Courier New",courier,monospace; background-color:#ffffff} .csharpcode pre {margin:0em} .csharpcode .rem {color:#008000} .csharpcode .kwrd {color:#0000ff} .csharpcode .str {color:#006080} .csharpcode .op {color:#0000c0} .csharpcode .preproc {color:#cc6633} .csharpcode .asp {background-color:#ffff00} .csharpcode .html {color:#800000} .csharpcode .attr {color:#ff0000} .csharpcode .alt {background-color:#f4f4f4; width:100%; margin:0em} .csharpcode .lnum {color:#606060} --> </style>

Visual Studio 2010利用宏添加注釋


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 四虎永久在线精品国产免费 | 亚洲一级免费视频 | 久久精品国产欧美日韩99热 | 直接看的毛片 | 亚洲国产一 | 黄色小视频在线免费观看 | 中文国产成人精品久久96 | 欧美日韩亚洲一区 | 日韩亚洲欧美在线爱色 | 黄片毛片 | 一区二区三区四区视频在线观看 | 久久成人在线观看 | 日日摸天天添天天添破 | 国产激情对白一区二区三区四 | 深夜福利视频网站 | 日本人wwwxxⅹ免费视频 | 日本在线播放一区 | 亚洲最新视频在线观看 | 精品四虎免费观看国产高清午夜 | 好吊妞视频一区二区 | 国产欧美一区二区另类精品 | 亚洲视频免费在线 | 欧美高清一区 | 米奇影视7777| 亚洲精品第一区二区在线 | 91久久在线 | 四虎网站1515hh四虎免费 | 亚拍一区| 成人亚洲在线观看 | 成人影院久久久久久影院 | 久久人人爽人人爽 | 欧美夜夜片a | er久99久热只有精品国产 | 免费九九视频 | 精品伊人久久久99热这里只 | 亚洲婷婷在线视频 | 久久久久久久91精品免费观看 | 日日爽爽 | 国产亚洲精品久久精品6 | 日韩一区二区三区在线观看 | 男人深夜影院 |