Gre*_*fey 15 c# visual-studio-2008
我真的想让VS2008自动缩进一个区域的内容.样本可能是最好的.
现在做什么:
#region [ Fields ]
public int Count;
public int Total;
#endregion
Run Code Online (Sandbox Code Playgroud)
我想要的是:
#region [ Fields ]
public int Count;
public int Total;
#endregion
Run Code Online (Sandbox Code Playgroud)
我怎样才能让VS做到这一点?
编辑:为了它的价值,VS 在VB.NET 中做到了这一点.
在大多数情况下,此宏应该可以工作:
Public Sub IndentRegions()
'Assume that the document has been smart formatted
Dim TS As TextSelection = DTE.ActiveDocument.Selection
TS.SelectAll()
Dim lines As String() = TS.Text.Split(vbNewLine)
Dim level As Integer = 0
TS.StartOfDocument()
While Not TS.ActivePoint.AtEndOfDocument
If lines(TS.ActivePoint.Line - 1).Trim().StartsWith("#endregion") Then
level = level - 1
End If
For i = 1 To level
TS.Indent()
Next
If lines(TS.ActivePoint.Line - 1).Trim().StartsWith("#region") Then
level = level + 1
End If
TS.LineDown()
TS.StartOfLine()
End While
End Sub
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4660 次 |
| 最近记录: |