This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Formatting, tabs vs spaces.


On Wed, Jul 16, 2008 at 8:33 AM, Rodolfo Lima <rodolfo@rodsoft.org> wrote:
> Paolo Carlini escreveu:
>
>> To be clear: I didn't mean to suggest *changing* tools, only considering
>> Emacs as a reference for configuring the others. For better and worse, it's
>> the reference for the GNU projects, nobody knowing a bit of computer science
>> history can seriously disagree.
>
> Yes, I know you didn't mean it because it wouldn't make sense, but I
> couldn't resist replying, sorry ;) Enough of flame wars.
>
> Regards,
> rod
>
>

I figured it out (I think). In emacs, hitting the tab key is like
invoking an "indent" function and not "insert a tab char here". This
magic function figures out the proper indent based on the context of
the code I guess. Vim does not do this by default, hitting the tab key
literally inserts the tab char and it will display according to
whatever "shiftwidth" (c-basic-offset equivalent) is set to (default 8
in both editors). However, vim has an option, "softtabwidth" that,
when set to 2, does what emacs does. Hitting tab "indents" by 2, but
whats saved to the file is

So it looks like setting softtabwidth to 2 is the magic required for
vim to mimic the behavior of emacs. It will insert "mod 8" tab chars
and pad the rest with spaces. Note that expandtab is not required and
will actually cause improper formatting by inserting 8 spaces when you
hit tab instead of the tab char. Even though the result will look the
same, it will not insert a literal tab char which is what emacs does.

See:
http://www.jwz.org/doc/tabs-vs-spaces.html

Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]