Skip to content

Instantly share code, notes, and snippets.

@dadhi
Last active October 26, 2017 09:19
Show Gist options
  • Save dadhi/6064310 to your computer and use it in GitHub Desktop.
Save dadhi/6064310 to your computer and use it in GitHub Desktop.
Visual Studio 2010 macros to set "Insert spaces" or "Keep tabs" in Tools -> Options -> Text Editor -> C# -> Tabs page. Thanks to answer http://stackoverflow.com/a/1721896/2492669. For those who switching between solutions with spaces and tabs. As for me, I have assigned macros on ctrl+shift+alt+s and ctrl+shift+alt+t and quite happy now.
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Public Module InsertTabsOrSpaces
Sub InsertTabs()
DTE.Properties("TextEditor", "CSharp").Item("InsertTabs").Value = True
End Sub
Sub InsertSpaces()
DTE.Properties("TextEditor", "CSharp").Item("InsertTabs").Value = False
End Sub
'For Debugging..
Sub ShowAvailableProperties()
Dim prop As EnvDTE.Property
Dim props As EnvDTE.Properties
props = DTE.Properties("TextEditor", "CSharp")
Try
' List each property name for the Options page
' and all of its possible values.
For Each prop In props
msg += "PROP NAME: " & prop.Name & vbCr
Next
MsgBox(msg)
Catch ex As System.Exception
MsgBox("ERROR: " & ex.Message)
End Try
End Sub
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment