On Wed, Dec 24, 2008 at 9:24 PM, Max Waterman wrote:
> This leads me to think that the person requesting this feature should use
> tabs and not spaces, and put a tab in the middle of the text to which he
> wishes to align.
>
> <tab>if (<tab>thisIsTrue ) {
> <tab><tab>DoThis();
> }
>
> ...or something like that.
>
> Of course, the flexibility to do what is asked/wanted would be nice, but I
> don't consider this particular case as being something that *should* be done
> because it's *the right way*. On the contrary, IMO, it's more a side case
> that is *the wrong way* but would be nice to be able to do. Yeah, I'm not
> afraid to say it's wrong (if that's what I think) ... religious or not :p
> ... let the flames begin ;)
I think you're still misunderstanding things. One last go at
explaining why this is the Right Way (which won't make much sense
unless you're using a fixed width font): consider a vim set up with
:set list listchars=tab:>- tabstop=8 shiftwidth=8 noexpandtab
Assuming this indent/alignment style is used, you could get code that
looked like this:
int main() {
>-------int returnval = 5; /* This is the value that I will return.
>------- It's nonzero, which means failure. */
>-------return returnval; /* This is where I return it. */
}
Note the nicely aligned comments at the end of the lines. If a person
viewing this code then decided that a tabstop of 8 is too wide, and
wanted to use tabstop=3 for more compact code, all he would need to do
is change tabstop to 3, and he would see this:
int main() {
>--int returnval = 5; /* This is the value that I will return.
>-- It's nonzero, which means failure. */
>--return returnval; /* This is where I return it. */
}
And the comments still line up! The advantage of this indentation
scheme is that changing tabstop will allow changing the width of the
code to fit personal preferences without hurting the alignment of
anything that was lined up. Compare this to what happens with the way
vim works now - let's say someone writes the same chunk of code with
:set ts=8 sw=8 noet:
int main() {
>-------int returnval = 5; /* This is the value that I will return.
>------->------->------- It's nonzero, which means failure. */
>-------return returnval; /* This is where I return it. */
}
Now, when our friend wants to display it with tabstop=3, things don't work out!
int main() {
>--int returnval = 5; /* This is the value that I will return.
>-->-->-- It's nonzero, which means failure. */
>--return returnval; /* This is where I return it. */
}
This is why using tabs for indenting a block, and spaces for aligning
code and comments within that block, is the nicest coding style to
work with. It allows anyone to change the width with which a tab is
displayed and change the width and look of the code, without screwing
up the alignment of comments and code.
~Matt
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---