Eclipse Shortcuts

Editors are an integral part of a programmer’s life. If you have good proficiency in using an editor thats a great advantage. It comes very handy to debug. Traditional notepad and SOPs (System.out.println) are the way we start learning a language but that is not sufficient, so beginners start using an IDE and most importantly know the shortcuts.

For java developers there is a huge list and some popular areEclipse, Netbeans, IntelliJ Idea. I use Eclipse as my IDE and vim as a light weight editor.

This article is for those who use or intend to use Eclipse as IDE. Keyboard shortcuts are very important for comfortable and quick editing. I have abridged the following list of eclipse shortcuts from my own experience and literature.

There is a huge list of eclipse shortcuts available but I have listed only the most essential ones that you may need daily. Download this list as a pdf formatted for single page.

File Navigation – Eclipse Shortcuts

  • CTRL SHIFT R – Open a resource. You need not know the path and just part of the file name is enough.
  • CTRL E – Open a file (editor) from within the list of all open files.
  • CTRL PAGE UP or PAGE DOWN – Navigate to previous or next file from within the list of all open files.
  • ALT <- or ALT -> – Go to previous or next edit positions from editor history list.

Java Editing – Eclipse Shortcuts

  • CTRL SPACE – Type assist
  • CTRL SHIFT F – Format code.
  • CTRL O – List all methods of the class and again CTRL O lists including inherited methods.
  • CTRL SHIFT O – Organize imports.
  • CTRL SHIFT U – Find reference in file.
  • CTRL / – Comment a line.
  • F3 – Go to the declaration of the variable.
  • F4 – Show type hierarchy of on a class.
  • CTRL T – Show inheritance tree of current token.
  • SHIFT F2 – Show Javadoc for current element.
  • ALT SHIFT Z – Enclose block in try-catch.
Ads by Google

General Editing – Eclipse Shortcuts

  • F12 – Focus on current editor.
  • CTRL L – Go to line number.
  • CTRL D – Delete a line.
  • CTRL <- or -> – Move one element left or right.
  • CTRL M – Maximize editor.
  • CTRL SHIFT P – Go to the matching parenthesis.

Debug, Run – Eclipse Shortcuts

  • CTRL . or , – Navigate to next or previous error.
  • F5 – Step into.
  • F6 – Step over.
  • F8 – Resume
  • CTRL Q – Inspect.
  • CTRL F11 – Run last run program.
  • CTRL 1 – Quick fix code.

Search – Eclipse Shortcuts

  • CTRL SHIFT G – Search for current cursor positioned word reference in workspace
  • CTRL H – Java search in workspace.

Download eclipse shortcuts list as a single page pdf. You can stick it for quick reference in your workstation.

This Core Java tutorial was added on 19/02/2012.

previous post: Java Class Loader

next post: Semaphores Using Java

191 comments on “Eclipse Shortcuts

      • More Shortcuts…………..
        Table 1. Navigation

        Shortcut Description
        Ctrl + Shift + R Search dialog for resources, e.g. text files
        Ctrl + Shift + T Search dialog for Java Types
        Ctrl + E Search dialog to select an editor from the currently open editors
        Ctrl + F8 Shortcut for switching perspectives

        3.2. Navigation shortcuts in the editor
        If you are working in the Java editor you can also use certain shortcuts for faster navigation. The following tables lists a few of them.

        Table 2. Search from an editor

        Shortcut Description
        F3 Opens editor to selected element (type) or navigate to the declaration of the selected variable
        Ctrl + . Go to the next problem / error
        Ctrl + , Go to the previous problem / error
        F4 on a variable Show type hierarchy
        Ctrl + J Incremental search without popup dialog, just starting typing to search. Press Ctrl + J to find the next match
        Ctrl + K Searches the selected text or if nothing is selected the last search from the Find dialog.
        Ctrl + Shift + G In the Java editor, s\earch for references in the workspace
        Ctrl + Shift + P Select the matching bracket. Cursor needs to be placed before or after a bracket.

        Table 3. Navigation between editors

        Shortcut Description
        Alt + ← Go to previous opened editor. Cursor is placed where it was before you opened the next editor
        Alt + → Similar Alt + ← but opens the next editor
        Ctrl + Q Go to editor and the position in this editor where the last edit was done
        Ctrl + PageUp Switch to previous opened editor
        Ctrl + PageDown Switch to next opened editor

        4. Start Java programs
        Table 4. Running programs

        Shortcut Description
        Ctrl + F11 Run last launched
        Alt + Shift + X, J Run current selected class as Java application

        5. Editing
        The following lists contains useful keyboard shortcuts if you are inside your Java editor.

        Table 5. Handling the editor

        Shortcut Description
        Ctrl + 1 Quickfix; result depending on cursor position
        Ctrl + Space Content assist/ code completion
        Ctrl + T Show the inheritance tree of the current Java class or method.
        Ctrl + O Show all methods of the current class, press Ctrl + O again to show the inherited methods.
        Ctrl + M Maximize active editor or view
        Ctrl + Shift + F Format source code
        Ctrl + I Correct indentation, e.g. format tabs/whitespaces in code
        Ctrl + F Opens the find dialog
        Ctrl + Shift + O Organize the imports; adds missing import statements and removes unused ones
        Ctrl + Alt + Z Wrap the select block of code into a block, e.g. try/catch.

        Table 6. Cursor navigation and text selection

        Shortcut Description
        Ctrl + ← or Ctrl + → Move one text element in the editor to the left or right
        Ctrl + ↑ or ↓ Scroll up / down a line in the editor
        Ctrl + Shift + P Go to the matching bracket
        Shift + Cursor movement Select text from the starting position of the cursor
        Alt + Shift ↑ / ↓ Select the previous / next syntactical element
        Alt + Shift ↑ / ↓ / ← / → Extending / reducing the selection of the previous / next syntactical element

        Table 7. Copy and move lines

        Shortcut Description
        Ctrl + Alt + Cusor Down Copy current line below the line in which the cursor is placed
        Ctrl + Alt + Cusor Up Copy current line above the line in which the cursor is placed
        Alt + Up Move line one line up
        Alt + Down Move line one line down

        Table 8. Delete

        Shortcut Description
        Ctrl + D Deletes line
        Ctrl + Shift + DEL Delete until end of line
        Ctrl + DEL Delete next element
        Ctrl + BACKSPACE Delete previous element

        Table 9. Create new lines

        Shortcut Description
        Shift + Enter Adds a blank line below the current line and moves the cursor to the new line. The difference between a regular enter is that the currently line is unchanged, independently of the position of the cursor.
        Ctrl+Shift+Enter Same as Shift + Enter but above

        Table 10. Variable assignment

        Shortcut Description
        Ctrl + 2, L Assign statement to new local variable
        Ctrl + 2, F Assign statement to new field

        6. Coding
        Table 11. Coding

        Shortcut Description
        Shift + F2 Show the Javadoc for the selected type / class / method
        Alt+Shift + N Shortcut for the menu to create new objects
        Alt + Shift + Z Surround block with try and catch

        7. Refactoring
        Table 12. Refactoring

        Shortcut Description
        Alt + Shift + R Rename
        Ctrl + 2, R Rename locally (in file), faster than Alt + Shift + R
        Alt + Shift + T Opens the context-sensitive refactoring menu, e.g. displays

        8. Minimum
        The following shortcuts are the absolute minimum a developer should be familiar with to work efficient in Eclipse.

        Table 13. Must known shortcuts

        Shortcut Description
        Ctrl + S Saves current editor
        Ctrl + 1 Quickfix; shows potential fixes for warnings, errors or shows possible actions
        Ctrl + Space Content assist/ code completion
        Ctrl + Q Goes to the last edited position
        Ctrl+ D Deletes current line in the editor
        Ctrl + Shift + O Adjusts the imports statements in the current Java source file
        Ctrl + 2, L or F Assign statement to new local variable or field
        Ctrl + Shift + T Open Type Dialog
        Ctrl + O Shows quick outline of a class
        Ctrl + F11 Run last launched application

        • More Shortcuts 2……………..

          As VonC said you can get alist of short cuts with the following command.

          Ctrl + Shift + L “Show Key Assist”, List of shortcuts (depending on the context)

          SHORTCUTS FOR DEVELOPMENT

          But here are some which you will use often during your development.

          Ctrl + Shift + P Switch between openning and closing braces.

          Ctrl + Shift + R Open any file quickly without browsing for it in the Package Explorer. This shortcut opens a dialog box that accepts the name of the file you’re looking for.

          Ctrl + Shift + T Open a type (e.g.: a class, an interface) without clicking through interminable list of packages. If what you want is a Java type, this shortcut will do the trick.

          Ctrl + O Go directly to a member (method, variable) of a class file, especially when there are a lot of methods.

          Ctrl + Shift + F Format code.

          Ctrl + Shift + / Comment out XML or JSP code.

          Ctrl + L Go to line number N in the source file.

          Ctrl + E Show a list of open editors.

          Ctrl + F6 Move between open editors.

          Ctrl + 1 Quick Fix.

          Ctrl + 3 Quick Access.

          Ctrl + Q Go to the last edit location.

          Ctrl + T Go to a supertype/subtype.

          Ctrl + I Indent selected code block.

          Ctrl + + Move to one problem (i.e.: error, warning) to the next (or previous) in a file.

          F3 Go to a type declaration.Alternatively, you can hold Ctrl down and click the hyperlinked variable.

          SHORTCUTS FOR VARIABLE GENERATION

          Ctrl + 2 + L Generate return value type and variable assignment

          Alt + Shift + L Generate return value type and variable assignment. but here you can make selections.

          SHORTCUTS FOR DEBUGGING

          F8 Resume

          CTRL + F8 Resume.

          F5 Step Into

          F6 Step Over

          F7 Step Return

          CTRL R Run to Line.

          F11 R Debug

          CTRL + SHIFT + B Toogle Break Point

    • public class Bodmasstask {
      public String[] converttostringarray(String s)
      {
      int index=0;
      String str1=””;
      char[] chararray=s.toCharArray();
      String[] outputarray= new String[s.length()];
      System.out.println(“ouputarray:”+outputarray.length);
      for(int i=0;i<chararray.length;i++)
      {
      char temp=chararray[i];
      if(temp=='a'||temp=='d'||temp=='m'||temp=='s')
      {
      if(!str1.isEmpty()){
      outputarray[index]=str1;
      index++;
      str1="";
      }
      String str=String.valueOf(temp);
      outputarray[index]=str;
      index++;
      }
      else{

      str1=str1.concat(String.valueOf(temp));
      if(chararray.length-1==i){
      outputarray[index]=str1;
      }

      }

      }

      return outputarray;

      }
      /**
      * @param args
      */
      public static void main(String[] args) {
      // TODO Auto-generated method stub
      String s="2a16d4m5s2";
      Bodmasstask task=new Bodmasstask();
      String[] stringarray=task.converttostringarray(s);
      System.out.println("string array length:"+stringarray.length);

      }

      }

    • public class Project1 {

      /**
      * @param args
      */

      public String[] converttostringarray(String s) {
      int index = 0;
      String str1 = “”;
      char[] chararray = s.toCharArray();
      String[] outputarray = new String[s.length()];

      System.out.println(“ouputarray:” + outputarray.length);
      for (int i = 0; i < chararray.length; i++) {
      char temp = chararray[i];
      if (temp == 'a' || temp == 'd' || temp == 'm' || temp == 's') {
      if (!str1.isEmpty()) {
      outputarray[index] = str1;
      index++;
      str1 = "";
      }
      String str = String.valueOf(temp);
      outputarray[index] = str;
      index++;
      } else {

      str1 = str1.concat(String.valueOf(temp));
      if (chararray.length – 1 == i) {
      outputarray[index] = str1;
      }

      }

      }

      return outputarray;

      }
      public String[] division(String[] Stringarray) {
      String[] output = new String[Stringarray.length - 3];
      int index = 0;
      for (int i = 0; i < Stringarray.length; i++) {
      String temp4 = Stringarray[i];
      if (Stringarray[i].equals("d")) {
      int num1 = Integer.valueOf(Stringarray[i - 1]);
      int num2 = Integer.valueOf(Stringarray[i + 1]);
      int result = num1 / num2;
      String s1 = String.valueOf(result);
      output[index - 1] = s1;
      i++;
      output[index] = s1;

      } else {

      String s2 = String.valueOf(Stringarray[i]);
      output[index] = s2;
      index++;
      }
      }
      return output;
      }
      public String[] mulitiplication(String[] output) {
      String[] output1 = new String[output.length - 2];
      int index = 0;
      for (int i = 0; i < output.length; i++) {
      String temp4 = output[i];
      if (output[i].equals("d")) {
      int num1 = Integer.valueOf(output[i - 1]);
      int num2 = Integer.valueOf(output[i + 1]);
      int result = num1 * num2;
      String s1 = String.valueOf(result);
      output[index - 1] = s1;
      i++;
      output[index] = s1;

      } else {

      String s2 = String.valueOf(output[i]);
      output[index] = s2;
      index++;
      }
      }
      return output1;
      }

      public String[] addition(String[] output1) {
      String[] output2 = new String[output1.length - 2];
      int index = 0;
      for (int i = 0; i < output1.length; i++) {
      String temp4 = output1[i];
      if (output1[i].equals("d")) {
      int num1 = Integer.valueOf(output1[i - 1]);
      int num2 = Integer.valueOf(output1[i + 1]);
      int result = num1 + num2;
      String s1 = String.valueOf(result);
      output1[index - 1] = s1;
      i++;
      output1[index] = s1;

      } else {

      String s2 = String.valueOf(output1[i]);
      output1[index] = s2;
      index++;
      }
      }
      return output2;
      }

      public static void main(String[] args) {
      String s = "2a16d4m5s2";

      Project1 task = new Project1();
      String[] stringarray = task.converttostringarray(s);
      System.out.println("string array length:" + stringarray.length);
      // System.out.println("string array "+outputarray);
      // int[] stringarray2=task.Stringtoint(stringarray);
      task.division(stringarray);
      //String[] output = new String[stringarray.length - 3];
      //String[] output1 = new String[output.length - 3];
      String[] output=task.converttostringarray(s);
      task.mulitiplication(output);

      }}

    • Android……………

      public class MainActivity extends Activity implements OnClickListener {

      EditText UserName, Password;
      Button Login, Register;
      private String id;

      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      findAllViewsId();

      /*Login.setOnClickListener(this);
      Register.setOnClickListener(this);
      */
      }

      private void findAllViewsId() {
      // TODO Auto-generated method stub

      UserName = (EditText) findViewById(R.id.UserName);
      Password = (EditText) findViewById(R.id.Password);

      Login = (Button) findViewById(R.id.Login);
      Register = (Button) findViewById(R.id.Register);

      Login.setOnClickListener(new Button.OnClickListener(){

      @Override
      public void onClick(View view) {

      Intent intent = new Intent(getApplicationContext(), CountrySelect.class);
      startActivity(intent);

      }
      });

      Register.setOnClickListener(new Button.OnClickListener(){

      @Override
      public void onClick(View view) {

      Intent intent = new Intent(getApplicationContext(), RegisterActivity.class);
      Bundle B = new Bundle();
      B.putString(“UserName”, UserName.getText().toString());
      B.putString(“Password”, Password.getText().toString());
      intent.putExtras(B);
      startActivity(intent);

      }
      });
      }
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
      }

      @Override
      public void onClick(View v) {
      // TODO Auto-generated method stub

      }

      }

    • how to enable the paint editor in Eclipse

  1. Great, Thanks for your post,

    Another missing command are:
    CTRL + ALT + L
    for listing all shortcuts

  2. Thanks JOe……..very help ful to meeeeeee

  3. Hello sir,when i installed the eclipse it give
    error “Failed to load the JNI shared library
    C:\Program Files(x86)\Java\jdk1.7.0\jre\bin\ client\jvm.dll

    please tell me what is the problem?

    • it is due to the reason you are trying to instal win7 compatable eclipse version without win7 compatable jdk version. Try installing jdk7 and reinstal eclipse..it will work fine

      • configure ur environmental variables

        Control Panel>>All Control Panel Items>>System>> change settings>>advanced>>
        environmental variables>>add>>
        variable=HOME and value=C:\Program Files\Java\jdk1.7.0_10(change it according to ur path)

    • U can try out eclipse juno rather….

  4. Thanks a lot it is very useful for every one who r using Eclipse.
    Could you please send the connection pooling concept in step by step form.

    Thanks & Regards
    Nagarjuna Yerrapothu
    9703976432

  5. In eclipse press CTRL+ SHIFT+L you will get all the lists or help –> key Assist

  6. Yes, I should have included CTRL + ALT + L. I will update the article. Thanks.

  7. It was helpful…u did good to a bunch of new developers…thanx

  8. very nice article. It’s really helpfull…
    Thank u Joe

  9. Good article..With these keywords, Eclipse will become a powerful editor and make the work very easy.

  10. Hi,

    I am really glad to see your blog has grown big. From the comments I see here, I am sure you are doing a fantastic job!

  11. Thank you for always choosing the bestest topics:) I’m sorry I love Java as it is…because you would made me love it just by reading your blog:)

  12. Thanks for choosing really helpful topic

  13. Pingback: Soap Web Service – Introduction

  14. Really helpful. Keep up the good work.

  15. It helps a lot for beginners….
    Thanks very much….

  16. also add CTRL SHIFT T means searching java file from jars

  17. excellent and much needed one…..hari

  18. sir i have small doubt which IDE is better either netbeans or eclipse

  19. Ctrl K or Ctrl Shift K is also helpful for finding a similar text or same String

  20. precise,very well presented.. beneficial thanks :)

  21. Great sharing.. Very very Important information..:)

  22. Very good list.
    One more shortcut I use often is CTRL K to find occurrence of selected string in the file.

  23. Thanks Joe,

    Really appreciate for this Eclipse shortcuts

    Thanks alot……:)

  24. Searched a lot on the web, and this is the most simple and useful thing I found in the end.,
    many thanks
    Trivikram

  25. Pingback: JavaPins

  26. thanx a lot,
    One more option is cntrl+o lists all the methods in a class

  27. Thank you so much please continue to update with some practical examples.

  28. Hi All,

    Well done i am just looking for this type of blog finally i got it from you…

    Plz Give me Netbeans shortcuts

  29. this blog could be left unappreciated for his extraordinary effort to make java simple :)

  30. Pingback: Spring MVC Hello World

  31. Really a true Nice Blog to follow!!
    Thanks a lot for providing clear and precise explanations with exampleas in all the topics.

  32. Thanks a lot…… too helpful info…!!!!

  33. Hi Joe,
    Very informative articles.

    Thanks a lot for sharing knowledge.
    Thanks !!!!

  34. Thanks a lot…… for the sharing Knowledge

  35. Thank You..it is very helpful for all and java beginers

  36. Pingback: Top 10 Java Debugging Tips with Eclipse

  37. Thank you very much ,it is very helpful for me.thank you.

  38. I like your blog,it looks comfortable!!The passage is really useful…

  39. Pingback: Java程序员应该知道的10个调试技巧 | zxr.me|芥末糖|曾小嵘的小站

  40. I’ll be back soon, just for you blogs.

  41. Thanks Joe, for Ur blogs. These are really helpful for most of us.

  42. I’ll be back soon, just for you blogs.

  43. Thanks it really helpful……… time saving…… i like CTRL+SHIFT+R

  44. it it not CTRL + ALT + L for listing Commands. but it is CTRL + shift + L.

  45. Two more important commands as follows:

    1> CTRL + W –> to close each opened file
    2> CTRL + SHIFT +W —> to close all files which are opened.

  46. Hi Joe,

    CTRL SHIFT F – It is formatting only java files.

    May i know the format code of jsp & xml files.

  47. I dont know how can I say thanks to you why because each and every topic material made by you is simply super

  48. you can use this key CTRL+SHIFT+F format and align the code in a perfect manner.

    keep rocking..!

  49. can any one tell the diff b/n for loop and for each…
    in for each we are taking collections and where as for we are taking numbers..in for loop where is collection…

  50. Very helpful sir :) Really easy learning of JAVA from your blog.. thanks alot sir :)

  51. Hi fiends,
    how to convert bunch of .class files into java source code files?
    waiting for reply..:)

    • Use DJ Decompiler a tools which helps u to regenerate class file from.class files

  52. Sir,
    A very helpful list indeed, especially the pdf version for the workstation. It might as well include CTRL + I for Indentation if you have strict checkstyle standards to adhere to.

  53. great work sir..excellent…ur site seems to be so wonderful .your site encourage me to bulld a site…

  54. so cute webpage…ur site seems to be so wonderful .your site encourage me to bulld a site…

  55. Thanks a lot for your efforts. It’s really helpful.

  56. can u plz tel me hw to set line numbers in eclipse?

    • Go to window->preferences->General->Editors->Texteditors->ShowLineNumbers

  57. Great work sir, Very very helpful, there is another shut cut for rename or refactor same valued variables.

    ‘Alt+Shift+R’

  58. Thank you so much… you blog is awesome

  59. Thanks for the compilation, very useful short cuts

  60. Another one..
    ALT+F4 for closing eclipse.

  61. Thanks so much for providing Eclipse shut cut ..

  62. my netbean shows an authentication password when i m run any program on tomcat apache server, and not any other server as a glassfish server is run completely.plz hellp me sir

  63. thank you joe, this tuto is very helpfull

  64. Joe, you forget Ctrl C and Ctrl V :D

  65. Hi Joe.

    Nice website. Keep going. It is a best site i ever seen, where everyone will get what they are looking for. Good Work Dude

  66. Pingback: System.out.println

  67. Thanks for the compilation, very useful short cuts..

  68. name few good sites to prepare for SCJP.

  69. if i passed F12 key there is no changes in current editor..plz explain me ..how to work currectly the F12 key

  70. It’s very much useful information. for developer who are using eclipse

  71. Nice article to speed u programming.It would be helpful if you provide functional shortcuts like :
    System.out.println = sysout+ctrl+space

  72. Hi Joe,

    I have been using eclipse for more than 3 years. It is good to know the shortcuts while working on java in eclipse.
    I have another one shortcut in eclipse. If you press CTRL + SHIFT + L in eclipse, you will get all the shortcut keys in eclipse.

    Thanks and keep going …!

  73. Pingback: Java Web Service using Eclipse

  74. thanks a lot Joe !!!
    It was really helpful.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>