yo1dog / vscode-cursor-align

Visual Studio Code Extension that aligns all cursors using spaces.
MIT License
22 stars 7 forks source link

Add command to automatically create columns of cursors within blocks of code #6

Closed ShimShamSam closed 3 years ago

ShimShamSam commented 5 years ago

I love the concept of this extension, but it would be really helpful if there was another command to automatically make a column of cursors out of existing cursors using changes in indentation or all-whitespace lines as boundaries. This would really help when aligning blocks of variables assignments.

It's probably easier to explain by example. I'm going to use the "|" pipe character to represent cursors.

const a = 123;
const |abc = 123;              // ----- Cursor on this line
const abcdef = 123;

function example() {
    const a = 123;
    const abc = 123;
    const abcdef = 123;
    const |abcdefgh = 123; // ----- Cursor on this line
    const bcdefg = 123;
    const bcd = 123;
    const b = 123;

    for(let i = 0; i < 100; ++i) {
    }
}

After the command is triggered:

const |a = 123;                // +
const |abc = 123;              // ----- Cursors added above and below
const |abcdef = 123;           // +
                               // ^^^^^ All whitespace line acts as boundary

function example() {           // vvvvv Change in indentation acts as boundary
    const |a = 123;        // +
    const |abc = 123;      // +
    const |abcdef = 123;   // +
    const |abcdefgh = 123; // ----- Cursors added above and below
    const |bcdefg = 123;   // +
    const |bcd = 123;      // +
    const |b = 123;        // +
                           // ^^^^^ All whitespace line acts as boundary (also technically a change in indentation)

    for(let i = 0; i < 100; ++i) {
    }
}
yo1dog commented 3 years ago

This extension is meant to be agnostic of context, allowing it to be universal and simple.

This request is out of scope for this extension, but could be a good candidate for its own. In fact, one may already exist.