Search code examples
eclipseformatlines-of-code

How to left-justify lines of code to the left edge of the window in eclipse


I have alot of code that has white space to the left of the lines of code in my eclipse project. I would like to select pieces of this code and remove the extra white spacing so each line lines up with the left edge of the window.


Solution

  • You can select the code you wish, and press SHIFT+TAB until the code lines up to the edge of the screen. You could also go to:

    Window->Preferences->general->Editors->Text Editors
    

    and when you're there, specify the tab width under:

    Displayed Tab Width.
    

    You can also customize Eclipses' formatter:

    Go to:

    Window->Preferences->Java->Code Style->Formatter
    

    Select the formatter and press Edit. Edit it to your desire.

    Then select the text you wish to format and press Ctrl+Shift+F