dail8859 / ElasticTabstops

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

Differentiate between tabs at line start and elsewhere #27

Closed eugenesvk closed 2 years ago

eugenesvk commented 2 years ago

One very useful application of elastic tabstops is to vertically align code comments on the right hand side At the same time it's also common to use tabs at the start of the line to visually show a nesting level — these don't need to be elastic, it's fine if this tab size is fixed (though the value of this fixed tab size is configurable)

However, these two conflict like so — try to insert at line 4 before //, it breaks the code alignment by making all the statements inside the while loop jump to the comment level

static int get_nof_tabs_between(int start, int end) {
    unsigned char current_char = 0; // comment1
    int tabs = 0;                   // comment2
    while (xx) { ⭾// inserting a tab here would make the lines below jump too far to the right
        if (current_char == '\t') {
            tabs++;
        }
        start = editor.PositionAfter(start);
    }
    return tabs;
}

Would it be possible to have and option to have two independent "alignment points" for Elastic Tabstops that shouldn't affect each other?:

dail8859 commented 2 years ago

So I understand the need, but I think this would be very difficult (not saying impossible) to support it without really messing things up in some cases, plus the whole method of calculating elastic tabstops comes from here.

I know alot of people use this for tab delimited files, which in that case they are all meant to be elastic since they delimit columns even if those columns are empty.

If someone could provide a really good solution to this I'd be willing to take a look, but knowing all the intricacies to calculate all the tabstops...it would be quite difficult.

eugenesvk commented 2 years ago

plus the whole method of calculating elastic tabstops comes from here.

Yeah, funny how his nice little diagram avoid this issue by having a convenient { separator without any tabs or a for (i = start... without any comments ;) This is indeed a deficiency is the original idea (the tabs before and after are kind of different beasts)

know alot of people use this for tab delimited files

isn't this the relatively easy part? You could toggle this kind of behavior per file type, so in .csv it would remain as is, but in .cpp it would switch to the more advanced one

But otherwise definitely appreciate the

it would be quite difficult

Hopefully if this elastic tabstops idea is ever going to fly wider than what's currently implemented then there could also be enough of devs' attention to improve it further