The most convenient solution I know is to create a set of Visual Studio macros to switch to the settings you want.
Go to Tools > Macros > Macros IDE
. There, in the tree on the left, right-click MyMacros
and choose Add > Add Module
. Give the module a name such as TabSize
. Within this module, create subs to change the settings you want. For instance:
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module TabSize
Sub Tab3()
SetTabAndIndentation(3)
End Sub
Sub Tab4()
SetTabAndIndentation(4)
End Sub
Function SetTabAndIndentation(ByVal value As Integer)
DTE.Properties("TextEditor", "AllLanguages").Item("TabSize").Value = value
DTE.Properties("TextEditor", "AllLanguages").Item("IndentSize").Value = value
End Function
End Module
There is no useful documentation I know of for the string parameters. If you need to set other options, such as "Keep Tabs", the easiest approach is to make these changes manually (unter Tools > Options
). Then, using Tools > Import and Export Settings
, save these settings as a vssettings file. This creates an XML file whose structure is the same as that needed for the method calls.
Finally, you can link these macros to command buttons or keyboard shortcuts via Tools > Customize
. Giving each macro a keyboard shortcut allows you to quickly toggle between settings.