Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reformat code associative array in new line in PhpStorm?

Tags:

php

phpstorm

Simply, I have now code like following:

$myArray = array( 'restaurant_id' => $res_id, 'menu_id' => $menu_id, 'food_id' => $foods_id);

After reformatting my array is show in one line. If array is long it is time wasting to navigate right side of the editor.

I want to reformat all of my code array snippet like following:

$myArray = array(
   'restaurant_id' => $res_id, 
   'menu_id' => $menu_id, 
   'food_id' => $foods_id);

How can I achieve that?

like image 790
karim_fci Avatar asked Sep 18 '15 17:09

karim_fci


People also ask

How to Reformat the code in PhpStorm?

Reformat File dialog The dialog appears when you press Ctrl+Alt+Shift+L in the editor of the current file. If you choose Code | Reformat Code from the main menu or press Ctrl+Alt+L , PhpStorm tries to reformat the source code of the specified scope automatically.

How to format html PhpStorm?

Go to Settings/Preferences | Editor | Code Style, select your programming language, and open the Wrapping and Braces tab. In the Keep when reformatting section, select the formatting rules which you want to ignore and deselect those which should be applied. Reformat your code ( Ctrl+Alt+L ).

How do I align code in Webstorm?

While in the editor, select the necessary code fragment and press Ctrl+Alt+I . If you need to adjust indentation settings, in the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. On the appropriate language page, on the Tabs and Indents tab, specify the appropriate indents options and click OK.


1 Answers

Finally! I found the problem. In File | Settings | Editor | Code Style | Wrapping and Braces | Array Initializer Option was do not wrap. For that reformat code was not working as expected.

like image 182
karim_fci Avatar answered Sep 28 '22 23:09

karim_fci