¿cómo alinear el texto con un carácter específico en phpstorm o webstorm?


Tengo este texto

$test1 = 'testing1';
$test1test1 = 'testing1';
$test1test1test1 = 'testing1';
$test1 = 'testing1';

Y me gustaría alinearlo así, usando pestañas,

$test1           = 'testing1';
$test1test1      = 'testing1';
$test1test1test1 = 'testing1';
$test1           = 'testing1';

¿Hay alguna forma de hacer esto en phpstorm o webstorm ?

Author: Korey Hinton, 2013-06-24

4 answers

Cmd+Alt+L (en Mac) o Ctrl+Alt+L (Win) y PHP Storm formatearán el código dependiendo de su estilo de código en Configuración. PARA establecer este estilo de código ir: Archivo - > Configuración - > Estilo de código - > PHP (elija aquí su idioma) - > Otro- > Alinear par clave - valor-marcar como marcado. Y luego presione Reformatear código (Ctrl + Alt + L) y listo. Obtendrá el código, con el estilo que escribe arriba.

 50
Author: LIAL,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-06-24 17:32:08

Para mí en PhpStorm 8.0.2 lo encontré aquí:

Settings -> Editor -> Code Style -> PHP -> Wrapping and Braces - > Align consecutive assignments

 39
Author: Sam,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-02-17 12:34:48

Opción de Formato en phpstorm 8

Ajustes > Estilo de código > php > Envoltura y llaves

introduzca la descripción de la imagen aquí

Marque ambas opciones Alinear campos en opción y Alinear Constante

¡Ahora puedes conseguir lo que quieres! :)

Fuente Blog de Jetbrains

 16
Author: maq,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-01-18 19:19:11

En PhpStorm 8 esa opción está en:

File -> Settings -> Code style -> PHP -> Wrapping and Braces -> Assignment statement
 7
Author: nwrman,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-10-28 02:52:40