0

Possible Duplicate:
Add increase/decrease tab indent buttons to the editor toolbar

Visual Studio has a feature that does exactly what i'm talking about if anyone is confused:

enter image description here

Basically it allows you to select several lines of text and either add or remove tabs. This would make formatting code on StackOverflow much easier. I will often copy code from my IDE that is 5 or 6 tabs deep and when I paste it into my question it keeps all those tabs, so it ends up like this:

                            Console.WriteLine("Hello world!");
                            Console.WriteLine("Hello world!");
                            Console.WriteLine("Hello world!");
                            Console.WriteLine("Hello world!");
                            Console.WriteLine("Hello world!");

It would be nice if I could just select those lines and remove unneeded tabs.

1
  • Been there, asked that.
    – user1228
    Commented Mar 14, 2011 at 20:43

1 Answer 1

6

There is a rough remove tabs functionality. I just tested it now. Starting with this:

                            Console.WriteLine("Hello world!");
                            Console.WriteLine("Hello world!");
                            Console.WriteLine("Hello world!");
                            Console.WriteLine("Hello world!");
                            Console.WriteLine("Hello world!");

I highlight it all, then hit nothing but the Code Formatting button 7 times, and...

Console.WriteLine("Hello world!");
Console.WriteLine("Hello world!");
Console.WriteLine("Hello world!");
Console.WriteLine("Hello world!");
Console.WriteLine("Hello world!");

It will only go in one direction until it hits the end, though that should be sufficient to most purposes. Doing this to your whole code block should keep everything in their proper alignment for your post.

There currently isn't any sort of built-in method to add tabs more than one deep.

3
  • Try the quote:code:quote:code pattern and see how that goes for you
    – random
    Commented Mar 14, 2011 at 19:28
  • 1
    @random It ends up very... Space Invaders.
    – Grace Note StaffMod
    Commented Mar 14, 2011 at 19:29
  • Ahh, very cool. Didn't realize you could do that. Commented Mar 14, 2011 at 20:07

Not the answer you're looking for? Browse other questions tagged .