score:0

ctrl + b: to build the project under c++

ctrl + shift + f: to format your code (c++)

score:0

of course all these shortcuts are available in the menus but who has time for that when you're in the "zone".

i like the code hot swapping.

score:0

of course if you can't find the binding you are looking for, or don't like the current binding window -> preferences -> general -> keys will allow you to change, add & delete the mappings of your key combo's.

score:0

if you build your project with ant you can assign a shortcut to "runs the last launched external tool" like ctrl+enter and it will repeat your last build. it is much easier than standard alt+shift+x,q also it helps with a bug in the latest eclipse that cannot find an ant build file in the project.

score:0

i'm really biased and this is blatant advertising...

still, i think my new eclipse plugin, nwire, is the best time saver you can get for eclipse. i developed it after years of working with eclipse, i just came to the conclusion that i need one tool to show me all the associations of my code instead of learning different tools and views.

check out the demo on my web site.

score:0

enabling 'ignore white space' in the compare/patch settings is a real time saver!

score:0

hit ctrl+s very often. it's ctrl+1's best friend.

score:0

i'm surprised no one mentioned the emacs keybinding setting available in eclipse. this is one of my favorite little features; it allows me to transition from emacs to eclipse with little adjustment in my navigation preferences.

windows->preferences->general->keys->scheme.

score:0

in

windows/preferences/general/keys

define

alt + c

for svn commit

alt + u

for svn update

shift + ctrl + n

for new class dialog.

score:0

the eclipse help contains a lot of useful resources. just search for "tips & tricks". in particular the "tips and tricks (jdt)" i found to be very useful.

score:1

ctrl+shift+enter to move the current line down by one and start typing above it.
ctrl+shift+x to capitalize the current selection, ctrl-shift-y to change it lowercase.
ctrl+. autocompletes the current word. this works for variables as well as strings (which is a huge timesaver for array keys, for example)

score:1

when debugging i find the "display" view really useful. it lets you type code (using auto complete) and lets you run/display the outcome of whatever you write.

give it a try!

score:1

quick assist: ctrl + 2, followed by f (assign to field), l(assign to local variable) and r (rename in file)

last edit location: ctrl+q

check out this article: http://dmy999.com/article/29/using-eclipse-efficiently

score:1

alt+shift+x + t

this will run your current file as a unit test.

score:1

ctrl-1 to convert if to conditional expression and back, split an assignment or join it back or do other such small manipulations. there is a list of these in the help.

score:1

depending on what time saver means to you...

adding todo and fixme in a comment automatically adds a task to the task list in eclipse. so if there is code you want to come back to, say you were debugging and need to do some research, you can do...

fixme means it is urgent, which puts a red ! in the task window
todo is normal urgency

//fixme: this accidentally deletes user accounts
user.account().delete();

//todo: add some validation before assigning everyone as admin
user.setprivilege("admin");

and then there are the setters/getters automatically being built. this is great if you are creating a bean or something. say you have declared a class such as:

public class somebean {
    private static int first_value = 0;
    private static int second_value = 1;
    ...
    private static int thousandth_value = 1000;
}

you can create all the variables, then right-click in the editor, go to source and then pick generate setters & getters. this will automatically create them for you.

score:1

shift-f2 goes to the javadoc for any method.

use it a lot. for libraries you need to configure the location , but for standard classes they are predefined by eclipse

score:1

ctrl-mouseclick (left) as an alternative for f3 to go to declaration.

score:1

ctrl+d to delete the current line

alt+up/down to move the current line or block of selected text up or down

ctrl+alt+up/down to copy/duplication the current line or block of selected text up or down

ctrl+alt+c svn commit (with subversive)

ctrl+alt+u svn update (with subversive)

score:1

i recently mapped alt-enter to the same command as ctrl-1. it's just a bit easier to get to.

i also use alt+shift+x &t a bunch, but i'm not a fan of how the integrated test runner works.

score:1

if you are using the f3 key to navigate to the source code of a method, you could often waste your time to switch to the the interface instead of going directly to the implementation class (there is often only one, for dao, service,... for example)

using ctrl+mouse pointer to one method of the code, you will be able to choose between directly going to the directly go to the implementation (the class) or the declaration (the interface)

more info about this tip here:

http://www.ibm.com/developerworks/opensource/library/os-eclipse-galnav/index.html

this is only available in galileo and you can use ctrl + t as well for the same.

score:1

double click next to an opening bracket will highlight all the code till the closing bracket, and vice versa.

score:1

install the mousefeed eclipse plugin. after installation, it will show you a popup with the keyboard shortcut whenever you click on a button or a menu item that is associated with a shortcut.

score:1

ctrl-f6 to cycle focus through open editor windows (with ctrl-shift-f6 to cycle backwards)

ctrl-f7 to cycle focus through eclipse views

ctrl-f8 to cycle eclipse perspectives

score:1

not so hidden feature ,but very less people use it and do not explore it template key board shortcut

and alex has explained about member sort

move lines

score:2

ctrl+f then tick the "regular expressions" checkbox. from that, you can search with regular expressions, but even more powerfully, you can include group matches in your replacement string ($1, $2, etc, or $0 for the whole match).

score:2

ctrl-alt-up/down to copy a line up (or down). that followed by alt-up/down is often much quicker than a copy-paste

score:2

don't know a keyboard shortcut to it, but select a local variable in a method, and then right click. under refactor is "convert local variable to field". very useful on occasions. just wish there was a shortcut for it!

score:2

ctrl-shift- up or down in java editor jumps to to nearest declaration of a method or a field in that direction.

score:2

one combination to rules them all.

ctl+shft+l

get the list of all these "hidden" features.

score:2

i am sorry if this is a duplicate, but i don't think i have seen this one mentioned here and i scanned over all of the posts:

word completion:

alt + /

is a really nice alternative to ctrl+space. it doesn't quite replace ctrl+space, but is much faster. and don't be afraid to press it multiple times, it will keep cycling over possible options.

score:2

alt+shift+z - to active the "surround with" sub menu. handy when have to surround with a try catch block.

score:2

ctrl + h searches/replaces through the whole workspace or project.

score:3

if you want to put a system.out.println("anything"); to your code you can simply do as follows: only write ", then mark the "" and press crtl-space up-arrow and enter (you should land on "sysout").

voila, there it is :)

score:3

how about:

ctrl-pgup and ctrl-pgdn to navigate through the open files in the editor (including the overflow section if you ctrl-pgdn all the way to the right).

score:3

you can ctrl-click on just about any type, field, method, or variable and eclipse will bring you to the declaration of that item:

ie:

  • on a local variable - brings you to the declaration statement in the function
  • on a member variable - brings you to the definition in a class file that the member is declared (or the parent class if it's not overridden in a child class
  • on a class - brings you to the top of the class file for that class

you can also ctrl-hover over a type to bring up the option to find an implementation. this is useful if you are using an interface and want to see what classes implement that interface. it also works to see what super-classes and subclasses might implement/override a certain function.

score:4

save actions rocks. there you can get your imports organized (ctrl+shift+o) and formatting of code (ctrl + shift + f). besides from that i love alt + shift + r for refactoring.

my favorite things is the plugins though: they might cause you to use more time but most of the time they give quality (subjective i know)

  • code coveragde (eclemma)
  • static analysis on source(pmd)
  • static analysis on byte code(findbugs)
  • checkstyle
  • springide.

then you start to rock with the mandatory source control plugins and the maven 2 plugin.

rock on!

score:4

ctrl + o is an popup outline view that lets you start typing to filter on a name

ctrl + f3 works similarly, but it can open other types' outlines based on where your cursor is.

turn on the save action to clean up your code and it will be automatically formatted and import optimized every time you save. to easily get to this option choose "windows|preferences" start type "save act" in the filter box and turn on the option.

in the new 3.4 release, turn on the "breadcrumb trail" at the top of the editor window. there's a new toolbar button for this.

score:4

ctrl + shift + p to find the matching brace. really useful while working with long codes.

score:5

ctrl-alt-h to open the call hierarchy of the selected method.

really useful on large codebases or unknown codebases

score:5

ctrl+, and ctrl+. move the text cursor to the next and previous error or warning (red or yellow squiggle) in the source. this gets really useful if you're dealing with a big block of dirty or broken code when you're in the depths of refactoring or pasting. combined with ctrl+1 for suggest fix you can quickly repair the code without having to move your hand to the mouse.

in fact, you barely have to lift your finger off ctrl...

score:5

a hidden gem is the conditional breakpoint. really useful for skipping over portions of loops, pausing if something is null or meets a certain value, etc... just right-click on the breakpoint, breakpoint properties --> enable condition. there's even code assist within the textbox!

score:7

ctrl+shift+l will show you all the currently available keyboard shortcuts

score:7

here is my collection of the most useful keyboard shortcuts for eclipse 3:

eclipse 3 favorite keyboard shortcuts. 
by -=maggus=-

navigate:

•   ctrl + shift + l – shows useful keyboard shortcuts in popup window 
•   ctrl + h – search.
•   ctrl + k – goes to next search match in a single file. shift + ctrl + k – goes to previous match.
•   f3 - goes to ‘declaration’ of something. same as ctrl + click.
•   ctrl + shift + g - use this on a method name or variable. it will search for references in the code (all the code) to that item.
•   ctrl + o – shows outline view of the current class or interface.
•   ctrl + t – shows class hierarchy of the current class or interface. f4 – shows the same in separate tab.
•   ctrl + shift + t - open type. search for any type globally in the workspace.
•   ctrl + shift + r – open resource. search for any file inside workspace.
•   ctrl + j – incremental search. similar to the search in firefox. it shows you results as you type. shift + ctrl +j - reverse incremental search.
•   ctrl + q – goes to the last edit location.
•   ctrl + left|right – go back/forward in history.
•   ctrl + l – go to line number.
•   ctrl + e – this will give you a list of all the source code windows that are currently open. you can arrow up or down on the items to go to a tab.
•   ctrl +pgup|pgdown – cycles through editor tabs.
•   ctrl + shift + up|down - bounces you up and down through the methods in the source code.
•   ctrl + f7 – switches between panes (views).
•   ctrl + ,|. – go to the previous/next error. great in combination with ctrl + 1.
•   ctrl + 1 on an error – brings up suggestions for fixing the error. the suggestions can be clicked.
•   ctrl + f4 – close one source window.

edit:

•   ctrl + space – auto-completion.
•   ctrl + / – toggle comment selected lines.
•   ctrl + shift + /|\ – block comment/uncomment selected lines.
•   ctrl + shift + f – quickly ‘formats’ your java code based on your preferences set up under window –> preferences.
•   ctrl + i – correct indentations.
•   alt + up|down – move the highlighted code up/down one line. if nothing is selected, selects the current line.
•   ctrl + d – delete row.
•   alt + shift + up|down|left|right – select increasing semantic units.
•   ctrl + shift + o – organize imports.
•   alt + shift + s – brings up “source” menu.
o   shift + alt + s, r – generate getter/setter.
o   shift + alt + s, o – generate constructor using fields.
o   shift + alt + s, c – generate constructor from superclass.
•   alt + shift + t – brings up “refactor” menu.
•   alt + shift + j – insert javadoc comment.
•   f2 – display javadoc popup for current item. shift + f2 – display javadoc in external browser.

run/debug:

•   f11 / ctrl + f11 – execute/debug.
•   ctrl + shift +b – toggle breakpoint.
•   when paused: f5 – step into, f6 – step over, f7 – step out, f8 – resume.
•   ctrl + f2 – terminate.

eof

score:7

not so hidden but imo the best trick.

assuming default settings (and you have'nt added new snippets)

highlight (or select) a text (string or variable)...press ctrl+space. hit end+enter. the "sysout" snippet is triggered which wraps the selection around as its parameter.

eg.

 "hello world!"

becomes
system.out.println("hello world!");

i love it so much that i've implemented a similar snippet for android's toast and log.i() huge time saver during manual debugging....

score:8

alt + shift + r to refactor and rename.

score:9

ctrl+alt+up or ctrl+alt+down to copy lines

score:9

ctrl+alt+h on a method to get the call hierarchy for it. fast way to see where it is called from.

score:10

a non-keyboard shortcut trick is to use commit sets in your team->synchronise view to organise your changes before committing.

set a change set to be the default, and all changes you make on files will be put in that set, making it easy to see what you have changed while working on a specific defect/feature, and other changes you had while testing etc.

score:10

ctrl+space, for anything, anywhere.

generate getters and setters.

create constructors using fields

extract method...

refactor->rename

ctrl+o for the quick outline. ctrl+o+ctrl+o for the inherited outline.

f4 to display a type hierarchy

open call hierarchy to display where a method is called from.

ctrl+shift+t to open a java type

ctrl+shift+r to open any resource.

alt + left or right to go forward or backwards through edit places in your documents (easy navigation)

override/implement methods if you know you're going to do a lot of methods (otherwise, ctrl+space is better for one at a time selection.

refactor->extract interface

refactor->pull up

refactor->push down

ctrl+shift+o for organize imports (when typing the general class name such as map, pressing ctrl+space and then selecting the appropriate class will import it directly for you).

ctrl+shift+f for formatting (although eclipse's built in formatter can be a little braindead for long lines of code)

edit: oh yeah, some debugging:

f5: step into (show me the details!)

f6: step over (i believe you, on to the next part...)

f7: step out (i thought i cared about this method, but it turns out i don't, get me out of here!)

f8: resume (go until the next breakpoint is reached)

ctrl+shift+i: inspect an expression. ctrl+shift+i+ctrl+shift+i: create a watch expression on the inspected expression.

conditional breakpoints: right click a breakpoint and you may set a condition that occurs which triggers its breaking the execution of the program (context assist, with ctrl+space, is available here!)

f11 - debug last launched (application)

ctrl+f11 - run last launched (application)

score:10

breakpoint on exception

eclipse let you set breakpoints based on where an exception occurs.
you access the option via the "j!" alt text http://help.eclipse.org/stable/topic/org.eclipse.jdt.doc.user/images/org.eclipse.jdt.debug.ui/elcl16/exc_catch.png icon in the debugging window.

alt text http://blogs.bytecode.com.au/glen/2007/04/06/images/2007/addexceptionwindow.png

the official help topic "add java exception breakpoint " has more on this.

  • the uncaught exception option is to suspend execution when an exception of the same type as the breakpoint is thrown in an uncaught location.
  • the caught exception option is to suspend execution when an exception of the same type as the breakpoint is thrown in a caught location.
  • do not forget the exception breakpoint suspend on subclass of this exception:
    to suspend execution when subclasses of the exception type are encountered.
    for example, if an exception breakpoint for runtimeexception is configured to suspend on subclasses, it will also be triggered by a nullpointerexception.

alt text http://help.eclipse.org/stable/topic/org.eclipse.jdt.doc.user/reference/breakpoints/images/ref-breakpoint_suspendsubclass.png

score:13

f3 has been my favorite, opens the definition for the selected item.

ctrl+shift+r has an interesting feature, you can use just the uppercase camel letters from a class when searching (such as typing cwar will show a result for classwithareallylongname).

alt+shift+w > package explorer makes life easier when browsing large projects.

score:14

nobody's mentioned the best one yet. click on a class or method name and press ctrl+t.

you get a quick type hierarchy. for a class name you see the entire class hierarchy. for a method name you get the hierarchy showing superclasses and subclasses, with implementations of that method distinguished from abstract mentions, or classes that don't mention the method.

this is huge when you are at an abstract method declaration and quickly want to see where it is implemented.

score:15

alt+shift+up arrow does escalating selection. alt+shift+down does the opposite.

score:15

alt+up or alt+down to move lines

score:15

ctrl + shift + m: changes a static method or static attribute reference of a class to a static import.

before

import x;

...
x.callsomething();

after

import static x.callsomething;

...
callsomething();

score:17

alt-shift-r stands for rename, not refactor. refactoring is a more general term (as defined by the book).

nevertheless, it is one of my favorite refactorings. others include:

extract local variable is especially useful when i don't remember (or bother to type) the result type of a method. assuming you have a method jdbctemplate createjdbctemplate() in your class, write some code such as this:

void somequery() {
    createjdbctemplate()
}

select the expression createjdbctemplate(), click alt-shift-l, type the name of variable and press enter.

void somequery() {
    jdbctemplate mytemplate = createjdbctemplate();
}

score:17

ctrl + d - to delete current line

score:17

absolutely, ctrl+q to go to last edit location. it is very useful just after being interrupted by phone, boss or others.

score:20

hippie expand/word complete, afaik inspired by emacs: will autocomplete any word in any editor based on other words in that file. autocomplete inside string literals in java code, in xml files, everywhere.

alt + /

score:22

there's an option to place the opening curly brace and a semicolon automagically in the "correct" position. you'll have to enable this - choose window/preferences and type "brace" in the searchbox - should be easily findable (no eclipse on this computer). the effect:

  • typing a semicolon anywhere on the line will place it at this lines end (as in word/openoffice: backspace if you'd like to have it in the original place)
  • typing an opening curly brace when you're just inside another pair of braces will place it at the end of this line - as in this example

("|" is the cursor):

if(i==0|)

typing "{" now will result in

if(i==0) {|

score:23

alt-up arrow moves the current selection up a line, alt-down arrow moves it down. i also use alt-shift-up/down arrow all the time. ctrl-k and ctrl-shift-k is quite handy, finding next/previous occurrence of the current selection (or the last find, if nothing is selected).

score:24

code completion supports camelcase, e.g., typing cwar will show a result for classwithareallylongname. start using this feature and you'll never type another long classname again.

(parts copied from another answer because i think answers w/ just one hint/tip are best for polling)

score:28

clicking on the return type in a method's declaration highlights all exit points of the method.

for instance:

1: public void foo()
2: {
3:   somecode();
4:    if ( blah ) return;
5:
6:    bar();
7: }

clicking on void will highlight the return on line 4 and the close } on line 7.

update: it even works for try{} catch blocks. if you put cursor on exception in the catch block and eclipse will highlight the probable methods which may throw that exception.

score:29

  • ctrl-shift-g : finds usages of the method or field under the cursor, absolutely necessary for understanding code
  • ctrl-f6 : navigate between the list of open editor windows, if you just type it once and let go you toggle back to the previous editor window, doing this successively is a nice way to jump back and forth
  • ctrl-t : on a class or method will show you the type hierarchy, very useful for finding implementations of an interface method for example

score:31

ctrl+3 brings up a type-ahead list of any menu command.

score:37

type 'syso' then press ctrl+space to expand it to system.out.println().

tres handy.

score:48

ctrl-j starts an incremental find.

hit ctrl-j, then start typing. use up/down to find previous/next instances of what you typed.

ctrl-shift-j searches backwards.

score:59

ctrl+shift+o to organize imports, which will format them nicely, remove unneeded imports, and add missing imports.

score:60

crtl+1 is my favorite. the quick fixes for the red-squiggles.

it is also located in the edit menu -> quick fix.

score:81

ctrl-shift-r and its buddy, ctrl-shift-t, to open a resource or type, respectively. resources includes all files in your open projects (including non-java files), and types includes java types either in your projects, or in a library included in the projects.

score:119

ctrl-2 something

seems that nobody mentioned ctrl-2 l (assign to new local variable) and ctrl-2 f (assign to a new field), these ones have changed how i write code.

previously, i was typing, say (| is cursor location):

display display = new |

and then i pushed ctrl-space to complete the constructor call. now i type:

new display()|

and press ctrl-2 l, which results in:

display display = new display()|

this really speeds things up. (ctrl-2 f does the same, but assigns to a new field rather than a new variable.)

another good shortcut is ctrl-2 r: rename in file. it is much faster than rename refactoring (alt-shift-r) when renaming things like local variables.

actually i went to keys customization preference page and assigned all sorts of additional quick fixes to ctrl-2-something. for example i now press ctrl-2 j to split/join variable declaration, ctrl-2 c to extract an inner class into top-level, ctrl-2 t to add throws declaration to the function, etc. there are tons of assignable quick fixes, go pick your favourite ones and assign them to ctrl-2 shortcuts.

templates

another favourite of mine in my “npe” template, defined as:

if (${arg:localvar} == null)
    throw new ${exception:link(nullpointerexception,illegalargumentexception)}("${arg:localvar} is null");

this allows me to quickly add null argument checks at the start of every function (especially ones that merely save the argument into a field or add it into a collection, especially constructors), which is great for detecting bugs early.

see more useful templates at www.tarantsov.com/eclipse/templates/. i won't list them all here because there are many, and because i often add new ones.

completion

a few code completion tricks:

  • camel case support mentioned in another answer: type ctm, get currenttimemillis
  • default constructor: in the class declaration with no default constructor push ctrl-space, the first choice will be to create one
  • overloading: in the class declaration start typing name of a method you can overload, ctrl-space, pick one
  • getter/setter creation: type “get”, ctrl-space, choose a getter to create; same with “is” and “set”

assign to a new field

this is how i add fields.

  1. if you have no constructors yet, add one. (ctrl-space anywhere in a class declaration, pick the first proposal.)

  2. add an argument (| is cursor position):

    public class myclass {
        public myclass(int something|) {
        }
    }
    
  3. press ctrl-1, choose “assign to a new field”. you get:

    public class myclass {
        private final object something;
        public myclass(object something) {
            this.something = something;
        }
    }
    
  4. add a null-pointer check if appropriate (see “npe” template above):

    public class myclass {
        private final object something;
        public myclass(object something) {
            npe|
            this.something = something;
        }
    }
    

    hit ctrl-space, get:

    public class myclass {
        private final object something;
        public myclass(object something) {
            if (something == null)
                throw new nullpointerexception("something is null");
            this.something = something;
        }
    }
    

a great time saver!

score:139

don't forget ctrl+shift+l, which displays a list of all the keyboard shortcut combinations (just in case you forget any of those listed here).


Related Query

More Query from same tag