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.
To format only selected lines within the script: Select the relevant lines. Go to Source | Format Active Elements -or- press Ctrl+I.
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).
Importing preferences for automatic formatting. Eclipse has the capability to do so some automatic formatting whenever a file that is being edited is saved.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With