Есть ли в PHPStorm автоформатирование php кода при сохранении?

Можно ли сделать автоформатирование кода в PHPStorm при сохранении, по типу как это можно сделать в VSCode, для JS файлов с помощью Prettier? Предположим есть строка кода
$table->integer('some_field')->nullable()->references('id')->on('some_table')->onDelete('CASCADE')->someMethod()->antotherMethod();

Она не укладывается в 80 символов, нужно чтобы IDE сделала "красиво" )
  • Вопрос задан
  • 1166 просмотров
Решения вопроса 1
@bkosun
Используйте плагин Save Actions или максросы:

Free Ctrl+S changing keyboard shortcut for "Save all"
  1. open File > Settings;
  2. search for "keymap" and open it;
  3. search "Save All" and double click the action "Save all";
  4. select "Remove Ctrl+S";
  5. double click "Save All" again and select "Add Keyboard Shortcut";
  6. select "Ctrl+Alt+Shift+S" as first stroke.
  7. Confirm and exit from Settings.


Record the macro
  1. Edit > Macros > Start Macro recording
  2. Press Ctrl+A, then Ctrl+Alt+L, then Up arrow, then Down arrow, and finally then Ctrl+Alt+Shift+S
  3. Stop recording the macro clicking on the Stop button on the bottom right of the page.
  4. Give this macro a name like "Format and Save"


Assign Ctrl+S to "Format and Save"
  1. open File > Settings;
  2. search for "keymap" and open it;
  3. search "Format and Save" and double click the action "Format and Save";
  4. select "Add Keyboard Shortcut";
  5. select "Ctrl+S" as first stroke.
  6. Confirm and exit from Settings.


https://stackoverflow.com/questions/12496669/code-...
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
New_Horizons
@New_Horizons
Бред:
ctrl + alt + L
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы