Eclipse Mars vs Intelij 15.0.1

NAVIGATING/SEARCHING/JUMPING/OPENING

0. Find action e.g. ‘key’ (to learn all shortcuts) or ‘last edit location’ (to learn this shortcut)
Intelij: Ctrl+Shift+A
Eclipse: Ctrl+3

1. Opening file e.g. Spring context

return new ClassPathXmlApplicationContext(new String[] {
    "beans-context.xml", "reports-context.xml"}, parentContext);

Intelij: Ctrl+Click on the file name in the code to open ‘beans-context.xml’ file automatically. Ctrl+Shift+N to navigate to file popup searching not only in the project code but also in jar dependency.
Eclipse: Ctrl+Shift+R at optionally highlighted or copied name to open resource popup (search only in the project)

2. Search everywhere – quick search text in classes/resources
Intelij: Shift+Shift (double shift)
Eclipse: install “Quick search” plugin and Ctrl+Shift+L

3. Open symbol (class, variable, method)
Intelij: Ctrl+Shift+Alt+N e.g TL.initialV to jump to ThreadLocal initialValue method
Eclipse: No direct equivalent, need to search by ‘search text everywhere’ or ‘find usage’

4. Open class – both project and jar files – supports camel case and wild card (*) name pattern (e.g. Thr*Map or TLMap for ThreadLocalMap)
Intelij: Ctrl+Nto navigate to class
Eclipse: Ctrl+Shift+T (open type)

5. Open method/variable/class declaration (on a highlighted interface type or interface method)
Intelij: Ctrl+Click or Ctrl+B
Eclipse: F3

6. Open interface/method implementation (on a highlighted interface type or interface method)
Intelij: Ctrl+Alt+Click or Ctrl+Alt+B
Eclipse: Ctrl+T

7. Find class/method/variable usage
Intelij: Alt+F7, additionally can group by production/test
Eclipse: Ctrl+Shift+G

8. Call hierarchy (SAME)
Intelij: Ctrl+Alt+H
Eclipse: Ctrl+Alt+H

9. Navigate back/forward
Intelij: Ctrl+Alt+left/right
Eclipse: Alt+left/right

10. Show recent files (SAME)
Intelij: Ctrl+E or Ctrl+Tab (and recently edited files: Ctrl+Shift+E)
Eclipse: Ctrl+E

11. Jump to Junit test or class under test
Intelij: Ctrl+Shift+T jump to test
Eclipse: not available

12. Show file structure
Intelij: Ctrl+F12
Eclipse: Ctrl+O outline

13. Go to previous/next error
Intelij: Shift+F2/F2 then Ctrl+F1 for error details
Eclipse: Ctrl+,/Ctrl+. For details go to or error icon on the left or open Problems view or error icon on the left

14. Highlight usages
Intelij: Click/Ctrl+Shift+F7
Eclipse: Click

14. Find occurrences in current file
Intelij: Ctrl+Alt+F7
Eclipse: Ctrl+Shift+U occurrences

15. Bookmarks
Intelij: F11 - toggle add/remove; Shift+F11 - view bookmarks
Eclipse: recommended Window/Preferences/General/Keys: Bookmark, bind new shortcuts: Alt+B, A for bookmark add current line; Alt+B, S for bookmark show

16. Find text in current file
Intelij: Ctrl+F find
Eclipse: Ctrl+F find

17. Find text in project (in files)
Intelij: Ctrl+Shift+F find in paths
Eclipse: Ctrl+H for Java Search

. Go to last edit location
Intelij: Ctrl + Shift + Backspace
Eclipse: Ctrl+Q

. Expand/collapse code block
Intelij: Ctrl + (Shift) + -/+ expand/collapse code block
Eclipse:

EDITING/REFACTORING
Refactor menu
Intelij: Ctrl + Alt+ Shift + T
Eclipse: Alt + Shift + T

0. Auto completion - start typing e.g. new Ar
Intelij: automatically opens popup to choose e.g. ArrayList (alternatively use Ctrl+Space for basis auto completion or popup), intelij also proposes ArrayList for new AL
Eclipse: press explicitly Ctrl+Space for auto completion or popup

0. Smart Auto completion
InteliJ:
A) start typing Set set = new and press;
Intelij: Ctrl+Space to get all suggestions (including primitives), BUT better press Ctrl+Shift+Space to get filtered options applicable for ONLY to the current context (here: classes implementing Set interface).
B) start typing Set set = and press Ctrl+Shift+Space TWICE to get results filtered to return Set of String like e.g. Collections.emptyList() or current class context related e.g.: applicationContext.getComponentNames();
C) start typing Set set = empty
to get a popup for Collections.emptyList()
D) just start typing: emptyS and press Ctrl+Alt+Space for popup with static fields/methods options e.g. Collections.emptySet() and Collections.emptyNavigableSet();
Eclipse: Ctrl+Space for basis auto completion popup. No InteliJ smart auto completion.

1. Selecting code syntactically (more/less)
Intelij: Ctrl+W/Ctrl+Shift+W
Eclipse: Alt+Shift+Up/Down

2. Rename
Intelij: Shift+F6
Eclipse: Ctrl+2,R or Alt+Shift+R rrename

3. Extract variable
Intelij: Ctrl+Alt+V local variable
A) allow to choose the type of the extracted variable to e.g. String, int etc)
B) lets you extract highlighted (Ctrl+W) part of the String
Eclipse: Ctrl+2,L Alt+Shift+L local variable
A) not possible to change the type
B) workaround - highlight part of the test, then quick fix (Ctrl+1) and choose 'Pick out selected part of String'

4. Extract method
Intelij: Ctrl+Alt+M method
Eclipse: Ctrl+2,M or Alt+Shift+M method

4. Extract field and choose how it is initialized
Intelij: Ctrl+Alt+F method
Eclipse: Ctrl+2,F, or go to refactoring menu Alt+Shift+T and choose 'Convert local variable to field' or assign a new shortcut Alt+Shift+F for field when 'Editing Java Source'. Note you need to create first local variable before conversion.

5. Extract variable to method parameter
Intelij: Ctrl+Alt+P parameter
Eclipse: Alt+Shift+T + P (introduce Parameter in popup) - suggest remapping to Alt+Shift+P for parameter

6. Inline (e.g. select local variable, method declaration or static final field to inline)
Intelij: Ctrl+Alt+N inline
Eclipse: Alt+Shift+I - inline

. Optimize/organize imports
Intelij: Ctrl+Alt+O optimize, recommended: File/Settings/Editor/General/Auto Import: Optimize imports on the fly, Add unambiguous imports on the fly
Eclipse: Ctrl+Shift+O organize, recommended Window/Preferences/Java/Editor/Save actions: Perform selected actions on save: Organize imports

. Quick fix
Intelij: Alt+Enter
Eclipse: Ctrl+1 (not only errors/warnings but also refactoring e.g. combine strings into one, pick out selected part of String, invert if-statement etc...)

. Safe delete
Intelij: Alt+Delete - inspects/view usages to check if can be safely deleted
Eclipse: not available

. Type migration
Intelij: move the cursor to the type e.g. String (not the variable name) to change (e.g. String -> int), then press Ctrl+Shift+F6 (or choose Refactoring/Type migration) and type 'int' in the migration popup. Fix conflicts, if found.
Eclipse: not available

. Find and replace code duplication
Intelij: go to the method body or constant to be used for duplicate check against rest of the code and replace the found duplicated code using that method or constant; no default shortcut available, go to Refactoring/Find and replace code duplication.
Eclipse: not available

. Join lines
Intelij: Ctrl+Shift+J
Eclipse: Ctrl+Alt+J

. Special handling of boolean type
Intelij: under refactoring (Ctrl+Alt+Shift+T) choose 'Invert boolean' (no default direct short-cut)
Eclipse: only invert if condition with quick fix (Ctrl+1)

. Statement auto completion
Intelij: Ctrl+Shift+Enter
Eclipse: enable by Window/Preferences/Java/Editor/Typing: Automatically insert at correct position: Semicolon and Braces

. Generalize declared type e.g from ArrayList to List
Intelij: available Shift+Tab when creating variable
Eclipse: recommended add new key e.g. Alt+Shit+E generalize declared type (Alt+Shift+G already taken for find usage)

. Toggle maximize editor
Intelij: Ctrl+Shift+F12
Eclipse: Ctrl+M maximize/minimize window

. Reformat code
Intelij: Alt+Shift+L (optionally Alt+Shift+Ctrl+L for reformatting options)
Eclipse: Ctrl+Shift+F

. Infer generic type arguments / generify (Generics)
Intelij: Refactor(Ctrl+Shift+Alt+T)/Generify
Eclipse: At+Shift+T,G or Refactor/Infer generic Type Arguments

. Pull up/push down
pull up = moves selected method/field to the super class
push down = moves selected method/field to the derived class(es)
Intelij: Refactor(Ctrl+Shift+Alt+T)/Pull Member Up or /Push Member Down
Eclipse: At+Shift+T,U for pull up, At+Shift+T,D for push down or Refactor/Pull Up or /Push down

. Templates
Intelij: Ctrl+J Insert a live template and Ctrl+Alt+J surround with live template (e.g. callable, try-with-resources, lock etc...)
Eclipse: Ctrl+Space, Ctrl+Space or add custom shortcut Alt+T for Quick assist (template proposal)

post file completion e.g. string.notEmpty
extract part of the text into variable by select Ctrl+W and refactor (Ctrl+Shift+Alt+T and choose variable or directly Ctrl+Alt+V)

Structural search - find patterns e.g for 'try and empty catch block'

Intelij: Settings: Ctrl+Alt+S

Spell check:
Intelij: gives warning: typo in word 'Multiple', move the cursor to highlighted work, then Alt+Enter Intention Action fix to see: Typo: rename to: (list with correct word proposals)
Eclipse: no warning detected for misspelled method name: shouldRetryMutlipleTimesAndHandleExceptionFromSubsystem

RUNNING
. Run Junit test for a current class
Intelij: Ctrl+Shift+F10
Eclipse: Alt+Shift+X,T

. Run history
Intelij: Alt+Shift+F10
Eclipse: no shortcut, Alt+R to go to Run menu and choose 3rd element 'Run History'

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s