Home > Net >  Add different number of spaces to multiple lines so that each line has equal amount of characters
Add different number of spaces to multiple lines so that each line has equal amount of characters

Time:09-26

Is there an easy way to add spaces to multiple lines so that each line has equal amount of characters?

Motivation, say I want to add '*' at end of each line

/***************************
* This is line 1. *
* Line2. *
* May be line3. *
* For sure this is line 4. *
****************************/

Without using any custom format program, is there a way in VS code to add different number of spaces just before the last '*' like so:

/***************************
* This is line 1.          *
* Line2                    *
* May be line3             *
* For sure this is line 4. *
****************************/

CodePudding user response:

  • select all the * at the lines that are incorrect
  • add as much spaces as needed to get all *'s beyond the correct position
  • Esc to get out of multi cursor
  • Place Multi Cursor on all lines at the position where you want the *'s
  • press Ctrl Delete
  • Esc to get out of multi cursor

CodePudding user response:

You can do this fairly simply with an extension I wrote, pad selected lines with spaces and add asterisk

You can do multiple selections at a time too.

  • Related