Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align to Nearest Tabstop #58

Open
orbisvicis opened this issue Mar 9, 2015 · 3 comments
Open

Align to Nearest Tabstop #58

orbisvicis opened this issue Mar 9, 2015 · 3 comments

Comments

@orbisvicis
Copy link

I opened godlygeek/tabular#38 before discovering this project, but I think the same issue applies. Any thoughts?

@smemsh
Copy link

smemsh commented Jan 4, 2016

I would like to second this. vim-easy-align is a great plugin, but it does not seem to allow aligning at a multiple of the tab stop, it only aligns naively to the right-most delimiter, after shrinking its preceding inter-word text to a single space. This does not look very good, the text has a bottleneck and doesn't align on tabular columns but at whatever random offset happens to be present depending on the length of the longest identifier. There is no "stretch" space to handle future additions that might be longer (and it will cause adding one single variable with a longer name to make the patch change all surrounding lines every time, for example).

It shouldn't just use "nearest" btw, it should allow some way to specify how many stops out. One way might be to preserve the spacing that precedes the delimiter of the chosen referent line, instead of collapsing it to one space. At least this allows a manual workaround (to manually place the delimiter of the longest identifier at the desired column) that won't get eaten by the alignment operation. Just don't move the delimiter to the left, leave it where it is (and as before, move the delimiters at lesser offsets to the right to align them)

this = that
foo = bar
this_is_a_test      = baz

could become:

this                = that
foo                 = bar
this_is_a_test      = baz

where today it is always:

this           = that
foo            = bar
this_is_a_test = baz

if we could add an ordinal somehow to say "space out this many tab stops" that would be even better but allowing manual placement of the furthest-offset one would provide a workaround...

(@orbisvicis I think maybe the issue should be re-described here in your first comment, instead of just referring to another project. The text of the linked issue doesn't really make sense anyways for this plugin because it uses a totally different syntax.)

@junegunn
Copy link
Owner

junegunn commented Jan 5, 2016

Thanks for the suggestion. But I don't think I'll have time for this at the moment. And this plugin is already quite complex with many number of options, adding another one while making sure that it's compatible with the pre-existing ones is not going to be trivial. FYI, easy-align sees the snippet in the following way

<----token---><left-margin><delimiter><right-margin>
this__________.............===========..............that
foo___________.............===========..............bar
this_is_a_test.............===========..............baz

Note that the length of delimiter is variable and we also need to consider how it should behave when stick_to_left (or <) is set.

@jeffreydwalter
Copy link

jeffreydwalter commented May 27, 2017

In case you guys are still interested. I hacked this plugin to tab align after the delimiter.

jeffreydwalter@5b4bcc3

This solution is by no means correct or complete, but it will align stuff after the delimiter on tab boundaries, based on the current tabstop setting.

Currently, this behavior is on all the time, and has no real integration with any of the other formatting options that deal with spacing between the delimiter and right-hand side tokens.

If this looks like it's headed in the right direction, I'd appreciate any help or feedback about how to take this feature the rest of the way.

So, something like

foo: bar
a:        baz
basdadads:   pizza

becomes

foo:        bar
a:          baz
basdadads:  pizza

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants