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

Questions and suggestion regarding table mode #40

Open
FichteFoll opened this issue Nov 5, 2014 · 7 comments
Open

Questions and suggestion regarding table mode #40

FichteFoll opened this issue Nov 5, 2014 · 7 comments

Comments

@FichteFoll
Copy link

FichteFoll commented Nov 5, 2014

So, recently I've discovered the table mode and been using it for my latex tables. There are, however, two things I don't quite understand yet.

  1. When does table mode get disabled? It appears that it happens whenever I edit a line that does not contain a matching regex delimiter but some docs would be nice.
  2. In latex it sometimes happens that there are special lines inbetween table contents but the table itself continoues over these. Table Mode would only align (to) adjacent lines and if a longer line happens to be split by such a special line, I get many different alignments in the same table. I found out that table mode considers all lines with selections to be part of the table, but I can't always re-select and change every affected line after I made a change to a separate block.

Example:

  \letter{S} \\ \hline
    Some text                      & the second column & short \\ \hline
    Some more text that is aligned & the second column & longer than short \\ \hline
  \letter{T} \\ \hline
    Totally related text & that is aligned differently, unfortunately & blah \\ \hline

Maybe there is a way to apply table mode only to certain regions/the current selection when you start it and then keep track of that using the add_regions API, which would also allow to visually highlight the area where it is enabled. Just an idea though.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/5784458-questions-and-suggestion-regarding-table-mode?utm_campaign=plugin&utm_content=tracker%2F334171&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F334171&utm_medium=issues&utm_source=github).
@randy3k
Copy link
Owner

randy3k commented Nov 5, 2014

  1. You are correct, the table mode is disabled when the current line and adjacent lines do not contains the regex. See the source. You can also disable it by pressing escape. Table mode is a relatively "new" stuff so there are no docs for it.
  2. If I understand correctly, you are using just & to align the table. However, if you use &|\\\\, you should be able to capture the intermediate lines. It seems interesting to use add_regions to highlight the regions.

@FichteFoll
Copy link
Author

  1. Yeah, that makes it align the whole thing but I don't actually want it to align the intermediate lines. It would be nice if I could select the whole table when enabling Table Mode, that would then be highlighted using add_regions and would proceed to work in the highlighted region until disabled.

I actually have an implementation for this in mind already but not really the time to do it.

@randy3k
Copy link
Owner

randy3k commented Nov 6, 2014

Check 80f78ad :) add_regions is used to memorize the regions of the table.

@FichteFoll
Copy link
Author

That should work for my case, I think. (waiting for release on PC)

I thought of something different (with the highlight thing that would allow you to edit somewhere else and then come back to the table later while still being in table mode already). If I find the time I'll try to do it myself, but I prolly won't.

@randy3k
Copy link
Owner

randy3k commented Nov 6, 2014

Oh, it is an even more interesting idea. But it requires some works to memorize both regex and the region.
I will probably not go for it, at least for now.

@FichteFoll
Copy link
Author

Indeed, but it sounds awesome. I guess the easiest would be to construct a unique add_regions key for each table mode regex (as in: embed the regex in the name and add some salt), add a list to the view's settings that includes all used keys and then test if the caret(s) is currently in one of the available regions. Then apply table mode to the whole region with the saved regex.

Or generate a unique key for each of the regions and save them in a dict with the regex as dict key and a list of matching region keys as its values.

@seabuck
Copy link

seabuck commented Dec 14, 2015

Hi, is it possible to make an expression that always aligns an expression to some position from the begining of the line?

Example:

test = one;

and also in a different region:

example = two;

-> always align '=' to position 9, so no matter the length of the previous word, both lines become:

Position:
123456789
test_____= one;

example_= one;

when you apply a single expression on both lines separately.

Thanks in advance.

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

No branches or pull requests

3 participants