Addition for 7.3: Automatic cluster aligning vertical tabs?

98 views
Skip to first unread message

Yarin

unread,
Feb 11, 2012, 1:06:49 AM2/11/12
to vim...@vim.org
Hello,
I've recently made a useful addition/extension for version 7.3:
It's basically elastic tabs, but it aligns the dust-covered vertical
tab character instead (because aligning the standard tab would break
lots of stuff). The diff is here:

http://naqua.net/p/vim/vim73_clustervtabs.diff

Trying it out as is simple as applying the diff, turning on
clustervtabs with :set cvt, and placing vtabs (for that, a mapping
is probably preferable, as Ctrl-K Ctrl-K Ctrl-K is annoying)

Is there any chance of getting this merged with VIM?

Thanks,
Yarin

Ben Fritz

unread,
Feb 12, 2012, 1:32:17 PM2/12/12
to vim_dev


On Feb 11, 12:06 am, Yarin <ya...@warpmail.net> wrote:
> Hello,
> I've recently made a useful addition/extension for version 7.3:
> It's basically elastic tabs, but it aligns the dust-covered vertical
> tab character instead (because aligning the standard tab would break
> lots of stuff). The diff is here:
>
> http://naqua.net/p/vim/vim73_clustervtabs.diff
>
> Trying it out as is simple as applying the diff, turning on
> clustervtabs with :set cvt, and placing vtabs (for that, a mapping
> is probably preferable, as Ctrl-K Ctrl-K Ctrl-K is annoying)


I haven't tried the patch yet, though I probably will at some point
for curiosity's sake. Elastic tabstops sound like a very interesting
idea!

I don't like two things conceptually about this patch, though.

First, why 'clustervtabs'? I like 'elastictabstop' or 'tabcolumnblock'
or something that describes better the purpose of the feature. (I get
the "column block" term from http://nickgravgaard.com/elastictabstops/
).

Secondly, while you are correct that modifying the behavior of real
tabs will affect a large amount of Vim's code, I think it is a bad
idea to hijack the meaning of vertical tabs rather than using
horizontal tabs as intended by the design of an elastic tabstop
feature. I feel using vertical tabs is a bad idea, because:

1. Opening the document created by Vim with this feature enabled, will
look completely wrong in other editors. One of the best parts of the
elastic tabstops concept is that documents using them will still look
"OK" in editors which don't support them.
2. Opening the document created in a different editor supporting
elastic tabstops, in Vim, will not show elastic tabstops, even though
Vim supposedly supports them.
3. Entering vertical tab characters is cumbersome, as you yourself
mention.
4. Vertical tab characters actually do have meaning (even if rarely or
never used these days), and "align text horizontally" is NOT that
meaning. I don't think Vim should willfully do the wrong thing here.
5. Opening a document created with vertical tabs in an old Vim, or a
Vim without this option enabled will (I believe) show a control
character in place of the tab.

If you feel working out all the kinks is too daunting a task for one
developer, you could consider making a clone of the repository on
Google Code, applying your patch, and getting people to help mature
the feature alongside Vim development. As I said I have not tried the
patch, but it seems you have a very good start which is functional
enough for people to start playing with, at least.

>
> Is there any chance of getting this merged with VIM?
>

I cannot imagine this patch will be included in 7.3, but perhaps 7.4
or 8.0 (obviously I cannot speak for Bram here, he may decide not to
include it at all). But there are other tab-related patches out there
which also might be considered for future Vims. One is variable
tabstops; a step up from strictly fixed-width tabstops, but not as
automatic or convenient as elastic tabstops (although perhaps more
versatile). The other I can think of is the ability for a wrapped line
(via :set 'wrap') to maintain the indent of the line for the wrapped
text. If I understand elastic tabstops properly, in that they set up
"column blocks", the latter would actually make a lot of sense for the
default behavior if the elastic tabstop option (whatever it ends up
being called) is enabled; wrapped text should conceptually stay in the
same column block as the text at the beginning of the line.

Ben Fritz

unread,
Feb 12, 2012, 1:57:50 PM2/12/12
to vim_dev


On Feb 11, 12:06 am, Yarin <ya...@warpmail.net> wrote:
> Hello,
> I've recently made a useful addition/extension for version 7.3:
> It's basically elastic tabs, but it aligns the dust-covered vertical
> tab character instead (because aligning the standard tab would break
> lots of stuff). The diff is here:
>
> http://naqua.net/p/vim/vim73_clustervtabs.diff
>

As to the patch itself, I have not looked in detail yet, but I do have
a few suggestions from a very brief glance:

1.) I believe Vim code uses C-style /*...*/ comments only, not C++-
style // comments. Some C compilers do not support the latter.
2.) You use "iff" instead of "if" in many places. Perhaps you meant
"if and only if" but that's probably not really needed for
understanding and it looks like a typo.
3.) There's a commented-out #define NO_CLUSTER_VTABS in feature.h
which should be removed.
4.) There's a few commented-out debug-like printf statements, and some
other commented code which should be removed, like "// || back_up ==
-2)" in screen.c
5.) I don't personally like seeing attribution/author comments in the
code (and neither do many others, http://www.producingoss.com/en/managing-volunteers.html#territoriality
), although a quick grep of the Vim source shows that it is done in a
handful of places; especially for complicated features like encryption
or specific GUIs. Personally, I'd shy away from a prominent in-code
attribution like the one in the patch. If you really want it, a very
short statement in the header comment would probably suffice. If this
ever gets included, Bram normally does mention developers of specific
features or patches in either the release notes or the patch
description.

Yarin

unread,
Feb 12, 2012, 3:19:40 PM2/12/12
to vim...@googlegroups.com
You raise some very good points.

I understand your concern about my trying to recycle the vtab.
Unfortunately, I can't find anything usable in Unicode.
Really, using the default tab character or a different one, is
bound to cause problems either way. I don't think there's any
winning on that front. :-( Ultimately I think I'll just have to
accept the breakage, and let end user know that he'll have to
configure it to be disable or enabled depending on file types for
best results. I already have it disabled by default, so...

I like the idea of changing the name to something like column
blocking tabstops. I'll be changing the name.

I don't think I'll clone or anything. I'm up to working out kinks,
though, I won't be very prompt. If I have to clone it then it's
already gotten to big and/or serious. If someone else wants to
though, be my guest.

I will change the commenting style and the iffs (as you guessed, iff
is not a typo). I'll also take care of the commented out code
snippets, I don't know why I didn't already do that.
And thanks for the link, you've successfully changed my stance on
attribution comments. :-S

Thanks for the input

Reply all
Reply to author
Forward
0 new messages