Useful Shortcuts in Eclipse - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Monday, 27 October 2014

Useful Shortcuts in Eclipse

How to remove unused imports from Eclipse...?


We often comes to the situation when we have lots of unused java packages import in our Eclipse Project.


Its always a better practice to remove such unused imports.


In this case we can direct use the shortcut by pressing Ctrl+Shift+O.


Just go to the class which contains unused imports and press Ctrl+Shift+O.

A key shortcut in Eclipse to copy the whole method body


Just place the cursor on the function anywhere in the body and press alt+shift+up several (5-10 if you start from empty selection) times to expand selection to include the whole method body.


How to Refactor (Rename) the selected element and all references..?

Juts select the element which you want to refactor and press Alt+Shift+R . It renames selected element and all references

How to Comment the lines..?

Just Select the lines you want to comment and press Ctrl + /.  It Comment / uncomment line or selection ( adds '//' )


Just Select the lines you want to comment and press Ctrl + Shift +  / .It adds Block Comment around selection ( adds '/... */' )

How to access the file properties of the files present in your project..?

Just Press Alt+Enter for the class you want to access file properties .

How to see the Line Numbers of the code in Eclipse..?

First Way is
Right click the gutter and select "Show Line Numbers". (Refer below pic)




Other way can be 

Window -> Preferences -> General -> Editors -> Text Editors -> Show line numbers.

How to indent the code..?

Just Select the code by pressing Ctrl+A, after Selecting Press Ctrl+I.

Ctrl+I  is the shortcut for correct indentation.

It will just format tabs/whitespaces in code.

How to Reformat the code..?

Pressing CTRL + SHIFT + F format all code that is format tabs/whitespaces and also divide code lines in a way that it is visible without horizontal scroll.

Reformat affects the whole source code and may rebreak your lines,

No comments:

Post a Comment