IntelliJ IDEA Tips and Tricks


Postfix Code Completion
some.var/if//try/twr/inst/throw/sout/
some.for/fori/forr/field/cast/null/nn

Shortcuts
Search Everywhere - Double-press Shift
Find action by name - command+shift+A
Show intention actions - alt+enter
Basic code completion - ctrl+space
Show type hierarchy    - ctrl+h
Delete lines - Command+Delete
Move caret to text start/end - Command+fn+left/right
Move caret to line start/end - fn+left/right or command+left/right

Navigation - link
Command+E - Recent files
Command+shift+E - Recent edit files
Go to Line              - Command+L
Show Javadoc        - Ctrl+J
Go to last edit location - Command+Shift+Delete
Open Javadoc  - F1
Alt+1 - open project view, Alt+5 - open debugger view

Add javadoc
- Typing /**
- Add shortcuts(Alt+Shift+J) to Fix doc comment

Class structure view (outline)
- Command+F12, Press Command +F12 again to show inherited methods

Format code - ctrl+alt+l
Organize import - ctrl+alt+O
Find in path = command+shift+F

Structure view - Command+7

Project View - Command+1

Increase font size (Zoom text)
Open Settings (Ctrl+Alt+S), search for "zoom", select Editor.
Select "Change font size (Zoom) with Ctrl+Mouse Wheel"

Live template - Command+J
main - generate main method
sout - just print System.out.println()
soutm - added Class name & method name
soutp - added parameter
soutv - added last variable name

soutf 
serr

psf – public static final
psfi – public static final int
psfs – public static final String

ifn – Inserts if null statement
inn – Inserts "if not null" statement

inst – Checks object type with instanceof and down-casts it
geti - create singleton getInstance method

Create new template - sfl4j log
Preferences > Editor > Live Template

Switch between views - Alt+F1
Find class        - Command+O
Find file by name - Command+Shift+O

Find/replace text string in the current file - Command+F/R
Find/replace text in the project or in the specified directory  - Command+Shift+F/R

Expand or collapse a code fragment in the editor - Command(+)+/-

Code completion - Ctrl+Space
Smart completion - Cmd+Shift+Space

Refactor This - Ctrl+T

Coding
Surround with action - alt+command+T
Overwrite methods - ctrl+O
Implement methods - ctrl+I

Refactor
Rename - shift+F6

Code generator - Command+N
Copy reference -> Copy qualified name in eclipse

Debugging
Quick evaluate expression - Command+alt+F8
Smart step into                   - Shift+F7
Step into                             - F7
Step over                            - F8
Step out                              - Shift + F8
Stop program                     - Command+F2

Scala
Type declaration action - ctrl+shift+B
Type info action - ctrl+shift+P
New scala worksheet

Preferences - Command+,
Inspections
Intentions

Keymap
Add shortcuts
Command+shift+W - Close all files in editors
Hide iml and idea files
Preferences > File > Settings > Editor > File Types and add ;*.iml;*.idea; at the end of the Ignore files and folders text box.

Configuration
Never use wildcard imports 

  • Settings > Code Style > Java > Imports tab
  • Set Class count to use import with '*' to a bigger value
  • Set Names count to use static import with '*' to a bigger value

Link with editor(eclipse)
Project view > gear icon > select Autoscroll from source
File -> Settings -> Editor -> General -> Show quick documentation on mouse move

Web Servers
Add -Xmx6g to vm options in server tab

IntelliJ problems view don't refresh itself when there is new compile error. Switch to other view then switch back.

IntelliJ show compile error at right side bar - unlike Eclipse which shows error/warnings in left side bar.

Configure > Project Defaults > Project Structure
-> Project tab -> Project SDK

When to Use IDEA
- Scala projects or projects that use SBT.

Trouble shooting
File | Invalidate Caches
Delete IDEA system directory
Messed up external libraries
Sometimes external libraries still keeps reference to old libraries that are not used any more, the workaround is to delete .idea/libraries internals and restart IntelliJ and reimport projects.

Resources
Meet IntelliJ IDEA

Labels

adsense (5) Algorithm (69) Algorithm Series (35) Android (7) ANT (6) bat (8) Big Data (7) Blogger (14) Bugs (6) Cache (5) Chrome (19) Code Example (29) Code Quality (7) Coding Skills (5) Database (7) Debug (16) Design (5) Dev Tips (63) Eclipse (32) Git (5) Google (33) Guava (7) How to (9) Http Client (8) IDE (7) Interview (88) J2EE (13) J2SE (49) Java (186) JavaScript (27) JSON (7) Learning code (9) Lesson Learned (6) Linux (26) Lucene-Solr (112) Mac (10) Maven (8) Network (9) Nutch2 (18) Performance (9) PowerShell (11) Problem Solving (11) Programmer Skills (6) regex (5) Scala (6) Security (9) Soft Skills (38) Spring (22) System Design (11) Testing (7) Text Mining (14) Tips (17) Tools (24) Troubleshooting (29) UIMA (9) Web Development (19) Windows (21) xml (5)