Tip for 1-click indentation settings changes in Visual Studio
I work at several projects at a time, and I have different settings/requirements concerning the code style for each of them. The main issue is ‘Tabs vs. Spaces’ option – the first project requires using tabs, the second – spaces. It’s obvious that going Tools -> Settings -> … is not an option for everyday use. Sounds like a good task for the automation macros, right?
- Navigate to Tools -> Macros -> Macros IDE (or use Alt+F11)
- Create new macros in Project Explorer (Project – Add Module)
- Write a method that changes the indentation settings:
Public Module TabsModule Public Sub ToggleTabs() Dim currentSetting As Boolean = DTE.Properties("TextEditor", "CSharp").Item("InsertTabs").Value DTE.Properties("TextEditor", "CSharp").Item("InsertTabs").Value = Not currentSetting End Sub End Module
Now you can use Macros Explorer (Alt+F8, also you can dock it as one of your panels) to quickly change settings (by double-clicking on the corresponding item name in the macros tree)