Formatting of bootscripts
bdubbs at swbell.net
Tue Jan 4 08:20:55 PST 2005
>This email is being sent to determine if the bootscripts should be laid
>out with spaces instead of tabs so everyone sees the same thing. THe
>only downside I can see is using the spacebar instead of the tab key. I
>used to know the vim setting that allowed a person to use the tab key
>and the file would be saved with spaces, not tabs. If anyone recalls
>that setting, please reply.
>Please voice your opinions, suggestions, etc.
In basic research on program readability, indentation of 2-4 characters
has been found to be optimal. Eight space indenting was evaluated to be
as bad as no indenting at all.
I teach students NOT to use tabs by inserting the following in .vimrc:
set expandtab "convert new tabs to spaces
set tabstop=4 "Number of spaces that a <Tab> in the file counts for.
set shiftwidth=4 "Number of spaces to use for each step of (auto)indent.
Tabs can be converted to spaces with :expandtab or spaces converted to
tabs with :retab
Similar things can be dome with emacs. less can be adjusted with export
Sometimes a conscientious programmer puts some effort into making their
code readable. Changing the tabstops can ruin that when a tab inserts
the equivalent of (say) 6 spaces for a 8 character tabstop. (Or 2
spaces for a 4 character tabstop). For that reason, I instruct my
students to use the entries in .vimrc above and it eliminates the
problem. Remember that programs/scripts are read many more times than
they are modified.
I realize that most of the responses above requested that tabs be left
in the file. That is personal preference (habit) based on learning how
to handle what is considerered by many programming methodology
researchers a poor practice started long ago when programming tools
(editors, line terminals, etc) were much more primitive.
All that said, I can live with either because my .vimrc and LESS
settings can handle it, but for the reasons above prefer spaces.
More information about the lfs-dev