Toggle Between Tabs & Spaces With Ease
Ever get yelled at for using tabs instead of spaces or spaces instead of tabs? Here’s your cure it toggles the text editor settings in visual studio for you.
Public Sub ToggleTabsAndSpaces() Dim keys As String() = { _ "Basic", _ "C/C++", _ "CSharp", _ "CSS", _ "HTML", _ "PL/SQL", _ "PlainText", _ "T-SQL", _ "XML"} Dim turnTabsOn As Boolean = True Dim msg = "Truning Tabs On" If DTE.Properties("TextEditor", keys(0)) _ .Item("InsertTabs").Value = True Then turnTabsOn = False msg = "Turning Tabs Off" End If IdeHelper.StatusBar(msg) IdeHelper.Output(msg) With DTE.Properties("TextEditor", "AllLanguages") .Item("TabSize").Value = 2 .Item("InsertTabs").Value = 2 End With For Each key As String In keys DTE.Properties("TextEditor", key) _ .Item("InsertTabs").Value = turnTabsOn Next End Sub
I mapped mine to Ctrl+Shift+=
If you need to find out what the names of the different editors are you can look them up in the registry.
- x64
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\AutomationProperties\TextEditor- x32
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\AutomationProperties\TextEditor
[tag]vs2k8, tip[/tag]