dail8859 / ElasticTabstops

Elastic Tabstops plugin for Notepad++
GNU General Public License v2.0
76 stars 16 forks source link

Add convert option #2

Closed A-R-C-A closed 8 years ago

A-R-C-A commented 8 years ago

This plugin would be even more useful when you include a convert option or a save/export feature to convert all the extended tabstops to a mixture of regular tabs (current tab settings) plus padding with spaces. So by using the same tab settings it would look everywhere the same. Now it's only usable with Npp.

dail8859 commented 8 years ago

I do plan on having some sort of support for converting to/from elastic tabstops eventually.

dail8859 commented 8 years ago

I see a few ways to do this:

  1. Convert all tabstops to spaces.
  2. Convert tabstops but keep "indentation" tabs. This meaning tabs that come before any non-tab character and are not stretched at all. This is most applicable with source code.
  3. Convert stretched tabstops so that it uses the "natural" width of tabs. This could cause a single tab character to get replace with multiple tabs and spaces.

1 and 2 are fairly easy and nearly identical. 3 would be quite a bit more difficult. Open to suggestions from anyone.

aaaxx commented 8 years ago

But as far as I can tell, your implementation doesn't treat indentation tabs differently; that is, the tab at the start of line is always aligned with the widest first tab within the same block of lines, regardless of whether that widest tab starts at the beginning of a line or somewhere within a line. This is something that has always bothered me, and I don't know if there's an official specification that mandates that behaviour, but it makes it impossible to use tabs for indentation in source code.

The way I think it should work is, it should ignore the start-of-line tabs and stretch only the ones that start within a line, and in addition to that, it should have a special case for TSV files that would work the way it does now, to be able to cope with empty cells in the first column.

With that in mind, I think the only option for the current implementation is to convert all tabs to spaces.

dail8859 commented 8 years ago

Thanks for the response. I hope I follow what you are saying.

your implementation doesn't treat indentation tabs differently

You are correct. Since within "indentation" tabs there is no text (i.e. empty cells), then it behaves as a "normal" tab.

but it makes it impossible to use tabs for indentation in source code.

I'm not sure what you mean. I've been using it for tab-indented source code just fine. There are cases where the first "cell" will get stretched if it needs to align with the cell above or below it.

But just because it has worked fine for what I'm doing certainly doesn't mean it's right for everyone, so I'm always open to suggestions.

aaaxx commented 8 years ago

I guess that was a bit hyperbolic. What I meant was, when you have an unindented line followed by an indented line and then you want to add trailing comments to both of them (using tabs, so that they align), the indented line will move right all the way to where the comment of the unindented line starts.

dail8859 commented 8 years ago

I'm assuming you mean trying to align something like this:

before

However it turns into:

after


I don't know if there's an official specification that mandates that behaviour

Guess I can't say "official" but this is working as it was originally intended.

I'll try to give it some thought see if there is a way to detect this kind of situation.

aaaxx commented 8 years ago

That's it. I suppose that should usually be an edge case in programming but I noticed it because I mostly deal with CSS.

A-R-C-A commented 8 years ago

The current implementation looks good, thanks.