Tabs vs Spaces

Andrew McNabb amcnabb at
Mon Nov 6 14:27:13 MST 2006

On Sat, Nov 04, 2006 at 09:47:12PM -0700, Doran Barton wrote:
> Note that this rule *doesn't* mean you can't use the Tab key to indent your
> code; only that the result of pressing that key can't actually be a tab.
> That's usually very easy to do under modern editors, most of which can easily
> be configured to convert tabs to spaces. For example, if you use vim, you can
> include the following directives in your .vimrc file:
> 	set tabstop=4	"An indentation every four columns"
> 	set expandtab	"Convert all tabs typed into spaces"
> 	set shiftwidth=4 "Indent/outdent by four columns"
> 	set shiftround	"Always indent/outdent to the nearest tabstop"

I like to keep tabstop=8 (the default), because most people in the world
set tabstop=8.  I like to be able to properly view tab characters that
other people have inserted.  If you use "softtabstop" instead of
"tabstop", you have the exact same behavior as your example (such as
indenting by 4 characters throughout the line), except that '\t' is 8
columns wide.  I think that's a good balance.

I put the following at the end of most files I make:

# vim: et sw=4 sts=4

"et" is "expandtab", "sw" is "shiftwidth", and "sts" is "softtabstop"

You shouldn't need "shiftround" unless shiftwidth != softtabstop, in
which case you should go sit in the corner.

Andrew McNabb
PGP Fingerprint: 8A17 B57C 6879 1863 DE55  8012 AB4D 6098 8826 6868

More information about the PLUG mailing list