Smart vs. Block vs. None: The Indenting Smackdown

Menu:  Tools -> Options -> Text Editor -> [Language] -> Tabs -> Indenting
Versions:  2008,2010
Published:  4/15/2010
Code:  vstipEdit0049

 

Download the seriously cool Tip of the Day Extension to get the daily tips delivered to your Start Page!

 

So you've seen the options looming there.  You see None, Block, and Smart Indenting and just can't help but wonder:  "Am I better off with my current indenting choice?"  Well never fear, today we reveal what each of these things do and how they can help you.

image

 

Let's begin with the option that most people have by default:  Smart Indenting.  This one is pretty cool.  So I'm creating a new method:

image

 

And I press ENTER after the curly brace:

image

 

Notice that Smart Indenting will pay attention to where it is at and automatically indent after the opening curly brace.  This is the "smart" part of the indenting since it knew that you pressed ENTER after an opening curly brace and assumed you wanted to indent.

 

 

 

Now let's look at Block indenting.  Given the same starting scenario:

image

 

We press ENTER after the curly brace:

image

 

In this case, the cursor maintains its current indent level and doesn't "smart" indent based on context.  Block indenting is the old school indenting style that is preferred by people who want control over when indenting happens. 

 

 

 

Of course, if you really want total control you can choose None indenting and turn off any indenting at all.  Again, assuming the same starting point:

image

 

Press ENTER after the curly brace:

image

 

"None" does exactly what it says and goes to column 1 after every time you press ENTER.  I personally don't prefer it but there are some that do.