Вопрос

As the title says, I want to format only selected lines of code. I know by pressing Ctrl + Shift +F formats whole file.

Formatting whole file is not good options as it will create lots of conflicts when I will commit the file. I changed a portion of the file (copied some code from internet etc.). Is there any easy way to format selected lines in eclipse. I have searched a lot but found no solution. I am working with PHP.

Это было полезно?

Решение

Highlight (left click, drag, left release) the lines you want to format, and press Ctrl + Shift + F, or right click and select Source -> Format.

For Java code, you have to highlight a complete piece of code (statement(s), method).

For PHP, I imagine you would still have to highlight a complete piece of code.

Tested on Windows version of Eclipse 4.2.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top