從eclipse 到IDEA 極簡入門
作為一個java開發工作者,工欲善其事必先利其器。我們經常用的就是eclipse 和 IEDA這兩個主流的開發工具。使用的一段時間,作為一個使用習慣eclipse轉化到IDEA需要知道什麼?
1,瞭解IDEA與eclipse之間概念區別
以是官方文件給出的區別,這樣就避免了我們在使用過程出現問題;
2,我們在寫程式碼經常會用到一些文字編輯的快捷,IEDA原生不做任何修改有如下的快捷鍵:
Eclipse |
IntelliJ IDEA |
||
Action |
Shortcut |
Action |
Shortcut |
Code completion |
Ctrl+Space |
Basic completion |
Ctrl+Space |
- |
- |
Smart completion |
Ctrl+Shift+Space |
- |
- |
Statement completion |
Ctrl+Shift+Enter |
Quick access |
Ctrl+3 |
Search everywhere |
Shift x 2 |
Maximize active view or editor |
Ctrl+M |
Hide all tool windows |
Ctrl+Shift+F12 |
Open type |
Ctrl+Shift+T |
Navigate to class |
Ctrl+N |
Open resource |
Ctrl+Shift+R |
Navigate to file |
Ctrl+Shift+N |
- |
- |
Navigate to symbol |
Ctrl+Shift+Alt+N |
Next view |
Ctrl+F7 |
- |
- |
- |
- |
Recent files |
Ctrl+E |
- |
- |
Switcher |
Ctrl+Tab |
Quick outline |
Ctrl+O |
File structure |
Ctrl+F12 |
Move lines |
Alt+Up/Down |
Move lines |
Shift+Alt+Up/Shift+Alt+Down |
Delete lines |
Ctrl+D |
Delete lines |
Ctrl+Y |
Quick fix |
Ctrl+1 |
Show intention action |
Alt+Enter |
Quick switch editor |
Ctrl+E |
Switcher |
Ctrl+Tab |
- |
- |
Recent files |
Ctrl+E |
Quick hierarchy |
Ctrl+T |
Navigate to type hierarchy |
Ctrl+H |
- |
- |
Navigate to method hierarchy |
Ctrl+Shift+H |
- |
- |
Show UML popup |
Ctrl+Alt+U |
Last edit location |
Ctrl+Q |
Last edit location |
Ctrl+Shift+Backspace |
Next editor |
Ctrl+F6 |
Select next tab |
Alt+Right |
Run |
Ctrl+Shift+F11 |
Run |
Shift+F10 |
Debug |
Ctrl+F11 |
Debug |
Shift+F9 |
Correct indentation |
Ctrl+I |
Auto-indent lines |
Ctrl+Alt+I |
Format |
Ctrl+Shift+F |
Reformat code |
Ctrl+Alt+L |
Surround with |
Ctrl+Alt+Z |
Surround with |
Ctrl+Alt+T |
- |
- |
Surround with live template |
Ctrl+Alt+J |
Open declaration |
F3 |
Navigate to declaration |
Ctrl+B |
- |
- |
Quick definition |
Ctrl+Shift+I |
Open type hierarchy |
F4 |
Navigate to type hierarchy |
Ctrl+H |
- |
- |
Show UML popup |
Ctrl+Alt+U |
References in workspace |
Ctrl+Shift+G |
Find usages |
Alt+F7 |
- |
- |
Show usages |
Ctrl+Alt+F7 |
- |
- |
Find usages settings |
Ctrl+Shift+Alt+F7 |
Open search dialog |
Ctrl+H |
Find in path |
Ctrl+Shift+F |
Occurrences in file |
Ctrl+Alt+U |
Highlight usages in file |
Ctrl+Shift+F7 |
Copy lines |
Ctrl+Alt+Down |
Duplicate lines |
Ctrl+D |
Extract local variable |
Ctrl+Alt+L |
Extract variable |
Ctrl+Alt+V |
Assign to field |
Ctrl+2/Ctrl+F |
Extract field |
Ctrl+Alt+F |
Show refactor quick menu |
Ctrl+Alt+T |
Refactor this |
Ctrl+Shift+Alt+T |
Rename |
Ctrl+Alt+R |
Rename |
Shift+F6 |
Go to line |
Ctrl+L |
Navigate to line |
Ctrl+G |
Structured selection |
Shift+Alt+Up/Shift+Alt+Down |
Select word at caret |
Ctrl+W/Ctrl+Shift+W |
Find next |
Ctrl+J |
Find next |
F3 |
Show in |
Ctrl+Alt+W |
Select in |
Alt+F1 |
Back |
Ctrl+[ |
Back |
Ctrl+Alt+Left |
Forward |
Ctrl+] |
Forward |
Ctrl+Alt+Right |
3,寫程式碼我們經常會忘記後面的這裡我們需要提示我們就可以使用下面的快捷鍵
Eclipse |
IntelliJ IDEA |
||
Action |
Shortcut |
Action |
Shortcut |
Code completion |
Ctrl+Space |
Basic completion |
Ctrl+Space |
- |
- |
Smart completion |
Ctrl+Shift+Space |
- |
- |
Statement completion |
Ctrl+Shift+Enter |
4,寫程式碼還會經常遇到是我們要快速的打印出內容或者寫一個for迴圈IDEA有如下的快捷鍵
Template |
Eclipse |
IntelliJ IDEA |
Define a main method |
main |
psvm |
Iterate over an array |
for |
itar |
Iterate over a collection |
for |
itco |
Iterate over a list |
for |
itli |
Iterate over an iterable using foreach syntax |
foreach |
iter |
Print to System.out |
sysout |
sout |
Print to System.err |
syserr |
serr |
Define a static field |
static_final |
psf |
5,說完寫程式碼,現在我們要怎麼樣快速找到一個程式碼,或者其引用可以用
Eclipse |
IntelliJ IDEA |
||
Action |
Shortcut |
Action |
Shortcut |
Open search dialog |
Ctrl+H |
Find in path |
Ctrl+Shift+F |
References in workspace |
Ctrl+Shift+G |
Find usages |
Alt+F7 |
- |
- |
Show usages |
Ctrl+Alt+F7 |
- |
- |
Find usages settings |
Ctrl+Shift+Alt+F7 |
Occurrences in file |
Ctrl+Alt+U |
Highlight usages in file |
Ctrl+F7 |
6,格式化程式碼
Eclipse |
IntelliJ IDEA |
||
Action |
Shortcut |
Action |
Shortcut |
Format |
Ctrl+Shift+F |
Reformat code |
Ctrl+Alt+L |
7,Debugging 除錯程式碼需要使用到的快捷鍵
Eclipse |
IntelliJ IDEA |
||
Action |
Shortcut |
Action |
Shortcut |
Step into |
F5 |
Step into |
F7 |
- |
- |
Smart step into |
Shift+F7 |
Step over |
F6 |
Step over |
F8 |
Step out |
F7 |
Step out |
Shift+F8 |
Resume |
F8 |
Resume |
F9 |
Toggle breakpoint |
Ctrl+Shift+B |
Toggle breakpoint |
Ctrl+F8 |
- |
- |
Evaluate expression |
Alt+F8 |
8,從eclipse工程匯入到IDEA
我們可以在開啟的歡迎頁面,點選 Import Project 匯入, 或者選擇 File | New | Project 匯入已經存在的原始碼。
如下我們要匯入的工程是maven工程或者是gradle工程可以如下圖進行匯入: