Horizontal list by vertical list and vice versa - IntelliJ IDEA based on IDE

Is there a key combination for converting a horizontal list to a vertical list and vice versa in IntelliJ IDEA and PhpStorm IDE based on it? For example, I have an array

$arr = [
    'test',
    'a' => 'b',
];

and I want to make it a one-line, I can select the text and use the Ctrl+ Shift+ J, I get

$arr = ['test', 'a' => 'b', ];

it is almost good, I can delete the latter ,manually. But how to do the opposite: convert a horizontal list to a vertical one? This is not only about arrays, but also about function signatures, for example

public function test($arg1, $arg2, $arg3, $arg4)

and function calls

test($arg1, $arg2, $arg3, $arg4);

sometimes the line gets too long, and you need to break it into reads as follows:

test(
    $arg1,
    $arg2,
    $arg3,
    $arg4
);

, , , - .

+4
1

IntelliJ IDEA 2019.2

, IDE: Alt + Enter, . , : Alt + Enter, .

gif image demonstrating new intention

IntelliJ IDEA 2019.2

()

, , " " Ctrl + Shift + J.

()

Realigner, ""> ""> " " ( Marketplace) Split Ctrl + Shift + Alt + P. , :

split by delimiter dialog

, . "" , , , Enter, . , Reformat Code. :

  1. Ctrl + Shift + Alt + P, Enter.
  2. Ctrl + Alt + L.

, , . : Realigner , . , , , , .

+1

Source: https://habr.com/ru/post/1615276/


All Articles