I would really like to have VS2008 automatically indent the contents of a region. A sample would probably be best.
What is does now:
#region [ Fields ]
public int Count;
public int Total;
#endregion
What I'd like is:
#region [ Fields ]
public int Count;
public int Total;
#endregion
How can I get VS to do this?
EDIT: For what its worth, VS does do this in VB.NET.
Technically, it is fine to either indent using the tab key or with the space bar. Indenting once with the tab key means just pressing the tab key once. Indenting once with the space bar means pressing the space bar 4 times.
This macro should work, for the most part:
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
Out of the box? You can't.
Change the background color to another color other than the main page background (I used silver on top of white) and it will give it that indented feel that you are looking for.
Options
> Environment
> Fonts and Colors
> Display Items: Preprocessor Keyword
and then change the item background
dropdown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With