Re: On Tabs and Spaces
- From
David <davvid@gmail.com>
- Date
- Oct 17, 2007, 03:41 UTC
- Message-ID
- <402731c90710162041q457c7dd3tf906ba0c6faf29ca@mail.gmail.com>
- In-Reply-To
- <20071016230952.GA18099@machine.or.cz>
On 10/16/07, Petr Baudis <pasky@suse.cz> wrote:
Show 23 quoted lines
> On Tue, Oct 16, 2007 at 07:40:26PM +0200, Sam Ravnborg wrote:
> > Tabs should be used for indent and not general alignment.
> >
> > Consider:
> > <tab>if (some long condition that
> > <tab>....&& spans two lines) {
> > <tab><tab>my_private_printf("bla bla bla"
> > <tab><tab>.................."more bla bla\n");
> > <tab><tab>}
> >
> > This will look good and align "more bla bla\n" as
> > intended no matter your tab setting.
> > But replacing the 8 spaces with a tab will
> > cause it to look bad.
>
> I'd so much love to have this and sometimes do this even manually, but
> does anyone have an idea how to make vim do this for me? I never got
> around to investigate this in depth or possibly make a patch...
>
> --
> Petr "Pasky" Baudis
> Early to rise and early to bed makes a male healthy and wealthy and dead.
> -- James ThurberHello I use both vim and emacs so I must be weird. Anyways, here's some useful vim settings that I've come across:
set tabstop=8 set softtabstop=8 set shiftwidth=8 set noexpandtab set list set listchars=<tab>:.\
The last two are extremely useful, especially if you're hacking on python. That's listchars=(less-than)tab(greater-than)(colon)(dot)(backslash)(space) (don't forget the space!).
That makes vim display tabs with a "." indicator, so you have a very clear view of when tabs are in use. This has helped me countless times.
You can use any character in there instead of dot. I actually use an extended ascii character since it looks nicer but I didn't want to risk email mangling it.
--
David