yo1dog / vscode-cursor-align

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

Feature request :: Right-align cursors/selections #12

Open whatsupbros opened 8 months ago

whatsupbros commented 8 months ago

A feature to right-align all cursors/selections by adding necessary white space from the left would be really nice.

This is useful when you have several "parts" in your statement, and need to align those parts between each other, in example, SELECT/FROM/WHERE/GROUP BY/ORDER BY parts in SQL queries.

Example

Original text

She loves pie.
My friend loves chocolate cake.
Everybody loves muffins.

Left-aligned at the second word (current functionality)

She       loves pie.
My friend loves chocolate cake.
Nobody    loves muffins.

Right-aligned at the second word (desired functionality)

      She loves pie.
My friend loves chocolate cake.
   Nobody loves muffins.

Real world usage example in SQL query

SELECT t1.field1,
       t2.field2,
       t2.field3
  FROM table1 t1,
       table2 t2
 WHERE t1.field1 = t2.field1
   AND t2.field2 = 'ABC'
   AND EXISTS ( SELECT NULL
                  FROM table3 t3
                 WHERE t3.field1 = t1.field1
                   AND t3.field2 = 123 )

As shown here, SELECT, FROM, WHERE, AND are right-aligned, which is required in some projects.