Search code examples
c#visual-studioindentation

Keep intentional indentations in Visual Studio


I am declaring a bunch of variables for a ribbon bar, and I want to indent them so they reflect the actual hierarchy. My code looks like this:

protected C1.Win.C1Ribbon.C1Ribbon rib;
    public C1.Win.C1Ribbon.RibbonTab rib_tabMain;
        public C1.Win.C1Ribbon.RibbonGroup rib_grpClipboard;
            public C1.Win.C1Ribbon.RibbonButton rib_btnCut;
            public C1.Win.C1Ribbon.RibbonSplitButton rib_btnSplitCopy;
                public C1.Win.C1Ribbon.RibbonButton rib_btnCopyPlain;
                public C1.Win.C1Ribbon.RibbonButton rib_btnCopyWithHeaders;
            public C1.Win.C1Ribbon.RibbonButton rib_btnPaste;

However, when I copy/paste this code to another place, then Visual Studio destroys all indentations. What can I do that Visual Studio is keeping the indentations?


Solution

  • After you insert (Ctrl + V), hit Undo once (Ctrl + Z). The first undo will only effect the formatting that Visual Studio applied automatically.