Intellij format complete file when I use Ctl+Atl+L for from menu code-> Reformat Code. This generates whole diff in git commit. I want to format only the code I have changed not the whole file. How can I do it?
Intellij format complete file when I use Ctl+Atl+L for from menu code-> Reformat Code. This generates whole diff in git commit. I want to format only the code I have changed not the whole file. How can I do it?
If your file is under version control, another option could be selecting Only VCS changed text from the Reformat dialog modal.
As it stated in the documentation
If this checkbox is selected, then reformatting will apply only to the files that have been changed locally, but not yet checked in to the repository. This checkbox is only available for the files under version control.
You have to select the portion of the code you'd like to format (in your case, the edited code). And then press Ctrl+Alt+L.
You can find more info here.
In case this is helpful to anyone, there is an option in PhpStorm under "Tools > Actions on Save" that allows you to reformat code on save. The option allows you to only reformat changed lines.
This effectively allows you to reformat changed lines only by pressing cmd + s