Home > OS >  VSCode - multiline selection - aligning with TAB
VSCode - multiline selection - aligning with TAB

Time:08-10

Quite often I have to change CSV files into PHP arrays and I almost got a quick way of doing it but there's last bit I can't figure out.

I get from this csv

label_a         label_b
test_a          test_b
test1111_a      test1111_b
test2222222_a   test2222222_b

to this:

"test_a" => "test_b",
"test1111_a" => "test1_b",
"test2222222_a" => "test2_b"

But I have a problem aligning the =>, I would like to align them like this:

"test_a"        => "test_b",
"test1111_a"    => "test1_b",
"test2222222_a" => "test2_b"

I keep my cursor here:

"test_a" |=> "test_b",
"test1111_a" |=> "test1_b",
"test2222222_a" |=> "test2_b"

but pressing tab, it obviously moves each line one tab (2 spaces in my case). Is there anyway to do it with VSCode? (maybe it's just wishful thinking)

CodePudding user response:

  • add spaces so all cursors are beyond the point you want the ==> to be
  • press home to get all cursors to position 1
  • move cursors to wanted position (ArrowRight)
  • press Ctrl Delete it will delete all spaces between cursors and =
  • Related