Skip to content

Align to existing alignments? #166

@josswright

Description

@josswright

I often run into the case where I'm adding new lines to a file that already has a large amount of existing text that I've previously aligned.

Is there, or could there be, any way to select a 'reference line' and align the new text to the existing spacing?

In my mind this would involve selecting a block of text to align, where the first line is something that is already aligned how I want it. Then using :EasyAlign as normal, with appropriate delimeters specified, but the first line becomes 'immutable' so that everything else snaps into place with that.

The obvious solution I have at the moment is that every time I need this I just select everything that I want aligned, but that can quite often involve some quite large amounts of text. I also quite often have blocks that I want aligned consistently that have other blocks of differently-aligned text between them, which makes this much trickier. (This is relatively common for config files.)

I have no idea how complicated this would be to implement, or how to handle breaking cases like there being insufficient space in a given alignment column for the text in the new line. (In that last case, I'd suggest just ignoring alignment for that line.) It would be very useful, though!

Thanks for the amazing plugin!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions