How to prohibit whole file reformatting, but allow reformatting of the selected text?

72 Views Asked by At

Sometimes I want to reformat specific parts of files, but I never want to accidentally reformat the whole file.

With the IntelliJ IDEA "Reformat code" action, if you configure it to "reformat selection", then it will reformat only the selection if you selected any text, but it will still reformat the whole file if none of the text is selected. I may sometimes forget about that and hit "Reformat code" not selecting any text, and when it is time to commit I find out that I reformatted a file I didn't want to reformat.

How can I disable reformatting the whole file when none of the text is selected, but still be able to reformat the text I explicitly selected?

1

There are 1 best solutions below

0
On BEST ANSWER

Set it in Reformat File Dialog - Ctrl + Shift + Alt + L enter image description here