Useful Keyboard Shortcut Keys for Eclipse and STS

Picture Courtesy: https://helpdeskgeek.com

Eclipse and Spring Tool Suite (STS) are the two important Integration Development Environments (IDE's) used massively in java development. The beginner and intermediately experienced java developers often find it a little time consuming, to do certain operations such as file search, finding a keyword in the code and many more when they are new to java IDE's. In my initial days, as a java student, I had experienced the similar issues because of which I always used to think, "When will I get some tips to know some keyboard shortcuts in such IDE's?".

Today, as an experienced java development enthusiast, here are some of the useful keyboard shortcut keys widely used by java developers while working with Eclipse and STS IDE's. The lists are categorized on the activities performed.


  • File Navigation

1. Ctrl+Shift+R : "Open a resource". This shortcut is used if the developers wants to find a specific file from a specific project. On using this command, a window will open asking to enter the file name. When file name is entered, the files having same name belonging to different projects appear. The developer can select any one of the file belonging to appropriate project.

2. Ctrl+E : "Open a file from within the list of all open files". This shortcut is used to find all the files that are open and present in the file editor window.


3. Ctrl+PgUp : "Navigate to previous file from within the list of all open files" . This shortcut is used when the developers wants to go to previous file within the list of open files in the file editor window.


4. Ctrl+PgDn : "Navigate to next file from within the list of all open files". This shortcut is used when the developers wants to go to next file within the list of open files in the file editor window.


5. Alt+<- (left arrow key) : "Go to previous edit positions from editor history list". This shortcut is used by the developers if they want to go to previous edit position in the file editor window. The edit position can be between 2 different files or within same file in the file editor window.


6. Alt+-> (Right arrow key) : "Go to next edit positions from editor history list". This shortcut is used by the developers if they want to go to next edit position in the file editor window. The edit position can be between 2 different files or within same file in the file editor window.


  • Java Editing

1. Ctrl+<space> : "Type Assist". This is used by the developer if they wants to get some predefined methods in classes. This shortcut gives the developers, some autocompletion recommendations such as method signatures, datatypes of a variable and many more for a predefined class. the developer selects the right one and continues to code. There is a way to even use keyboard shortcut for printing the output. The developer needs to type 'sysout' and click 'Ctrl+<space>', the entire command System.out.println along with parentheses () appears and the developer can directly provide the string or the message inside the parentheses. This reduces the coding efforts for developers.

2. Ctrl+Shift+F : "Format Code". This shortcut is used by developers to change the font of the code to look more presentable.


3. Ctrl+O : "List all methods of the class". This command will list all the methods defined in the class. The developers can select any method which he wants to call in that class.


4. Ctrl+/ : "Single line comment". The developer can select a line and click ctrl+/ and a single line comment '//' will appear on that selected line. The same shortcut can also be used to uncomment the same line.


5. Ctrl+Shift+/ : "Multi-line comment". The developer can select more than one line of code and use this shortcut and those lines will be commented in multiline comment format '/**/'. To uncomment use Ctrl+Shift+\ command (note the backslash).


6. Ctrl+D : "Delete a line". This shortcut is used by the developer to delete a line from the code.


7. Ctrl+Hover mouse : The developer gets 'Open Declaration', 'Open Initialization' and 'Open Datatype' of a function and a variable in the file by hovering mouse on that particular function or variable respectively while clicking Ctrl. If the developer selects 'Open Declaration' then, the control will go to the declaration line of that particular variable or function. If he selects 'Open Initialization' then, the control will go to initialization part of the function in any particular file within that project. If he clicks on 'Open Datatype' then, the developer will get the datatype of the function or the variable.


  • Debug and Run

1. F5 : "Step into". This key is used by the developers when the code is running on debugging mode. When the developer clicks on F5, the debugger executes line by line of the code.

2. F6 : "Step over". This key is used by developers to get into functions or subroutines while debugging the code without entering into the definition.


3. F7 : "Return". This key is used by the developer to come out of the functions and subroutines while debugging.


4. F8 : "Continue". This key is used to jump to next breakpoint if available. Otherwise it executes the whole program and comes out of it.


5. Ctrl+F11 : "Run Last Run Program". This shortcut is used by developers to run the last run or build of the program.


  • General Search

1. Ctrl+alt+G : Developers use this shortcut to search for current cursor positioned word reference in workspace.

2. Ctrl+H : This shortcut is used to search variables or words in any file such as java, javascript and others.


3. Ctrl+F : This shortcut is used to find any word or variable in that particular window.


Conclusion

The keyboard shortcuts in STS and Eclipse are plenty to discuss. I have discussed few of those which I have used while coding. If you know more keyboard shortcuts, have any feedback or suggestions then, please feel free to use the comment box below.



Stay tuned for more updates on "How to enable keyboard shortcuts in eclipse or STS IDE's".


Comments

  1. Much needed shortcuts in developer's field. You made my life easier 😃

    ReplyDelete

Post a Comment