Most Useful Keyboard Shortcuts For Beginner Eclipse IDE Us

 Most Useful Keyboard Shortcuts For Beginner Eclipse IDE Us

8 Most Useful Keyboard Shortcuts

I recently had two pair-programming assignments, each in Java and each with a separate partner. Going into this without much knowledge, my first partner suggested using Eclipse IDE, and that turned out to be a great choice. If you’re just starting out in Java, Eclipse is the way to go.

In the past, I’d tried learning the notorious VIM editor, but despite all the VIM tutorials out there, I found the learning curve too steep. Eclipse is much easier to grasp: you can see a list of all the files in your Java (or Android for that matter) project in the package explorer, easily navigate to the desired function with the outline window, get suggestions for functions, imports, and more.

Fortunately for me, my first partner taught me a number of useful workflow keyboard shortcuts, which I then passed on to my second partner who knew as little as I did. As newbie-friendly as Eclipse’s interface is, you owe it to yourself to learn these keyboard shortcuts. They’ll boost your productivity even further, guaranteed.

1. Organize Imports (Ctrl + Shift + O)

Whether you’re working with Java’s native libraries and classes or incorporating third-party frameworks into your code, one thing is true: in order to use a class, you have to first import the class before Eclipse will identify it as valid and available for code autocompletion (real-time typing suggestions).

But who has time to memorize every single package path for every single class in every single library? You can let Eclipse handle it for you using the Ctrl + Shift + O shortcut, which automatically imports unrecognized classes in code.

For example, if you have this bit of code:

public class Hello { public static void main(String[] args) { ArrayList list = new ArrayList(); } }

And then use the Organize Imports shortcut, it becomes like this:

import java.util.ArrayList; public class Hello { public static void main(String[] args) { ArrayList list = new ArrayList(); } }

Instead of typing import lines by hand, you can just write code as normal until you see the red squiggly lines (indicating unrecognized classes), then hit the Organize Imports shortcut.

Note that this shortcut also removes unused imports (in cases where you deleted code) and sorts the import statements by package.

2. Correct Indentation (Ctrl + I)

Code readability is important, not only for you (so you can come back at a later time and understand what you wrote) but for anyone else who may look at your code (partners, professors, open source contributors). Proper indentation is essential.

Does your code often look like this?

public void insertHead(int x) { Link newLink = new Link(x); if (isEmpty()) tail = newLink; else head.previous = newLink; newLink.next = head; head = newLink; }

Maybe you wrote it that way, or maybe you copy-pasted from elsewhere. Either way, the good news is that Eclipse makes it trivially easy to fix: highlight the portion of code that’s hard to read, then use the Ctrl + I shortcut to instantly bring it to proper indentation:

public void insertHead(int x) { Link newLink = new Link(x); if (isEmpty()) tail = newLink; else head.previous = newLink; newLink.next = head; head = newLink; }

You can change how Eclipse handles indentation by going to Window > Preferences, then in the left panel navigate to Java > Code Style > Formatter > Edit… > Indentation. Learn more about how to write clean code.

3. Delete Current Line (Ctrl + D)

When coding in Java, it’s natural to remove entire lines of code at a time. The worst way to do this? Highlight with the mouse, then hit Backspace. The rookie way to do this? Hit the End key, hold Shift, hit the Home key, then Backspace. But the pro way? Simply hit Ctrl + D:



4. Autocomplete Recommendation (Ctrl + Space)

Java is unfortunately known for being extremely verbose — the names of classes, methods, and variables are some of the longest in the entire programming industry. Typing them all by hand every single time? Not my idea of a fun time.

Here’s what you do instead: type the first few letters of the class, method, or variable you want, then hit Ctrl + Space. This brings up a list of autocompletion recommendations along with method signatures, variable types, and more. Select the right one, hit Enter, and keep coding.



Features like autocompletion are some of the reasons why IDEs trump text editors.Text Editors vs. IDEs: Which One Is Better For Programmers?Text Editors vs. IDEs: Which One Is Better For Programmers?Choosing between an advanced IDE and a simpler text editor can be hard. We offer some insight to help you make that decision.READ MORE

5. System.out.println (“sysout” and Ctrl + Space)

When working with console applications, you’ll need to use System.out.println() for printing messages. But because this is so cumbersome, Eclipse has a quick shortcut for you: type “sysout” (without the quotes), then hit Ctrl + Space.

The best part? The cursor is immediately placed within the method call’s parentheses, so you start typing the message right away:


6. Search Entire Project (Ctrl + H)

When working on large codebases, it’s easy to forget where you declared certain classes, methods, or variables. Instead of wasting time combing through directories by hand, use the Search Entire Project prompt with the Ctrl + Hshortcut.

By default, it comes with four search types: File Search, Task Search, Git Search, and Java Search. You’ll mostly use Java Search, which only searches through source files, but the other three can be useful in their own ways.



7. Run Application (Ctrl + F11)

The first time you run a new project, you should do it through Run > Run As… > Java Application. But after that, you can speed things up with the Ctrl + F11 shortcut, which runs the current project using the same configuration as the last time the project ran.



8. Rename (Alt + Shift + R)

Here’s the thing about class, method, and variable names: once declared, they can get referenced dozens, hundreds, or even thousands of time throughout a project. Now imagine if you ever need to change the name of a class, method, or variable. It could take hours (or days!) renaming every single reference.

Or you can right-click on the name, select Refactor > Rename, type in the new name, and have Eclipse change every single reference in the entire project in a second. Even faster, you can click on the name, hit Alt + Shift + R, type in the new name, and hit Enter. Bam, done!




Comments

Popular posts from this blog

The Best Apps and Add-Ons to Improve Your Writing

Best Free Online HTML Editors to Test Your Code

New update in I phone " X "