Một số macro bạn thấy hữu ích trong Visual Studio để thao tác mã và tự động hóa là gì?Bạn có bất kỳ macro được đề xuất nào cho Microsoft Visual Studio không?
Trả lời
Bạn cũng có thể muốn thêm vào các đoạn mã, chúng giúp tăng tốc thời gian phát triển và tăng năng suất.
Đoạn mã VB chuẩn đi kèm với cài đặt mặc định. Đoạn mã C# phải được tải xuống và thêm riêng biệt. (Liên kết dưới đây cho những người này)
Theo như macro đi, tôi thường không sử dụng bất kỳ nhưng làm việc với Visual studio 2005 cuốn sách có một số khá tốt trong đó.
C# Code Snippets Link: http://www.codinghorror.com/blog/files/ms-csharp-snippets.7z.zip (Jeff Atwood với điều kiện liên kết) HIH
@RZachary - Tôi nghĩ rằng các đoạn mã độc lập đủ các macro mà tôi đã đi trước và tạo ra một câu hỏi mới cho chúng. Nó có thể được tìm thấy ở đây. – rjzii
Đây là một trong những tiện tôi sử dụng trên HTML và XML file:
''''replaceunicodechars.vb
Option Strict Off
Option Explicit Off
Imports EnvDTE
Imports System.Diagnostics
Public Module ReplaceUnicodeChars
Sub ReplaceUnicodeChars()
DTE.ExecuteCommand("Edit.Find")
ReplaceAllChar(ChrW(8230), "…") ' ellipses
ReplaceAllChar(ChrW(8220), "“") ' left double quote
ReplaceAllChar(ChrW(8221), "”") ' right double quote
ReplaceAllChar(ChrW(8216), "‘") ' left single quote
ReplaceAllChar(ChrW(8217), "’") ' right single quote
ReplaceAllChar(ChrW(8211), "–") ' en dash
ReplaceAllChar(ChrW(8212), "—") ' em dash
ReplaceAllChar(ChrW(176), "°") ' °
ReplaceAllChar(ChrW(188), "¼") ' ¼
ReplaceAllChar(ChrW(189), "½") ' ½
ReplaceAllChar(ChrW(169), "©") ' ©
ReplaceAllChar(ChrW(174), "®") ' ®
ReplaceAllChar(ChrW(8224), "†") ' dagger
ReplaceAllChar(ChrW(8225), "‡") ' double-dagger
ReplaceAllChar(ChrW(185), "¹") ' ¹
ReplaceAllChar(ChrW(178), "²") ' ²
ReplaceAllChar(ChrW(179), "³") ' ³
ReplaceAllChar(ChrW(153), "™") ' ™
''ReplaceAllChar(ChrW(0), "�")
DTE.Windows.Item(Constants.vsWindowKindFindReplace).Close()
End Sub
Sub ReplaceAllChar(ByVal findWhat, ByVal replaceWith)
DTE.Find.FindWhat = findWhat
DTE.Find.ReplaceWith = replaceWith
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocument
DTE.Find.MatchCase = False
DTE.Find.MatchWholeWord = False
DTE.Find.MatchInHiddenText = True
DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
DTE.Find.Execute()
End Sub
End Module
Nó rất hữu ích khi bạn phải thực hiện bất kỳ kiểu nhập dữ liệu nào và muốn thoát khỏi mọi thứ cùng một lúc.
Đây là một trong tôi đã tạo cho phép bạn dễ dàng thay đổi Target Framework Version của tất cả các dự án trong một dung dịch: http://geekswithblogs.net/sdorman/archive/2008/07/18/visual-studio-2008-and-targetframeworkversion.aspx
Tôi đang sử dụng Jean-Paul Boodhoo 's BDD macro. Nó thay thế các ký tự khoảng trống bằng dấu gạch dưới trong dòng tiêu đề của chữ ký phương thức. Bằng cách này tôi có thể gõ tên của một trường hợp thử nghiệm, ví dụ, như một câu bình thường, nhấn một phím tắt bàn phím và tôi có chữ ký phương pháp hợp lệ.
Đây là macro của tôi để đóng giải pháp, xóa tệp intellisense và mở lại giải pháp. Cần thiết nếu bạn đang làm việc trong native C++.
Sub UpdateIntellisense()
Dim solution As Solution = DTE.Solution
Dim filename As String = solution.FullName
Dim ncbFile As System.Text.StringBuilder = New System.Text.StringBuilder
ncbFile.Append(System.IO.Path.GetDirectoryName(filename) + "\")
ncbFile.Append(System.IO.Path.GetFileNameWithoutExtension(filename))
ncbFile.Append(".ncb")
solution.Close(True)
System.IO.File.Delete(ncbFile.ToString())
solution.Open(filename)
End Sub
Nó có bị xóa không? –