I made a change in the blogger configuration to ease the later work when blogging. It is possible that older entries are not correctly formatted.

Showing posts with label shortcuts. Show all posts
Showing posts with label shortcuts. Show all posts

Thursday, 14 January 2010

Coole Eclipse Shortcuts

I found this link on http://viralpatel.net/blogs/2009/07/20-very-useful-eclipse-ide-shortcuts-for-developers.html.

I found the following shortcuts really great:

# Alt + Shift + L : Extract to Local Variable

Say you have the following method:

public void myTest(){ String finalVariable = "first part" + "second part"+ "third part"; }

if you select "first part" + "second part" and use the short cut :

Alt + Shift + L : Extract to Local Variable

Then eclipse ask for the name of the new local variable, e.g firstTwoParts, and the method looks like:

public void myTest(){
  String firstTwoParts = "first part" + "second part";
  String finalVariable = firstTwoParts + "third part";
}

# Alt + Shift + M : Extract to Method

The same also works with methods. Say you have the following method:

public final static void main(String[] args){
  if (args.length >2){
   System.out.println(args[0]);
   System.out.println(args[1]);
  }
}
if you select the whole if statement up to the }, and use the shortcut: Alt + Shift + M eclipse prompts for the name of the method and creates the parameter, for args.

# Alt + Shift + W : show the class in the package view.

Well I did not know that. But this is very useful, because I often need it.

# Ctrl+Q : Last edit

There is also a button to find this. But a short cut is even better.

# Alt + Left or Alt + Right : Navigate Left and Right

I knew this one but this is also very useful, since it is much quicker than using the mouse every time.