天天看點

更好的使用IntelliJ IDEA

一   快捷鍵的使用      

1.文本編輯

删除 ctr + y

複制 ctr + d

2.智能提示

提示 ctr + space

智能提示 ctr + shift + space

完成目前語句 ctr + shift + enter

建議提示為參數 ctr + alt + p

對代碼重新排列格式 ctrl + alt + l

組織導入,對imports進行優化 ctrl + alt + o

3.位置定位

定位到下一個或上一個錯誤 f2 / shift + f2

定位檔案頭 ctr+g (定位到檔案行數)

定位檔案尾 ctr+g 

定位到代碼塊開始 ctr + [

定位到代碼塊結束 ctr + ]

回到最近的視窗 f12

回到之前的檔案 alt + left

回到之後的檔案 alt + right

定位到最後編輯位置 ctrl + shift + backspace

從tool window或其他window切換到檔案編輯 esc

關閉最近打開的視窗 shift + esc

4.類、方法、檔案定位

查找類 ctr + n

查找檔案 ctrl + shift + n

符号定位 ctrl + alt + shift + n

檢視檔案結構 ctrl + f12

最近打開的檔案 ctr + e

定位下一個方法 alt + down

定位上一個方法 alt + up

檢視方法參數資訊 ctr + p

檢視方法、類的doc ctr + q

5.類、方法的結構檢視、定位

跳到類或方法的聲明 ctr + b

定位到類的父類、接口 ctr + u

檢視類的繼承結構 ctr + h

檢視方法的繼承結構 ctr + shift + h

檢視類或方法被調用情況 ctr + alt +h 

原地參看類、方法的聲明 ctrl + shift + i

6.運作與調試

ctrl + f9 make project (compile modifed and dependent)

ctrl + shift + f9 compile selected file, package or module

alt + shift + f10 select configuration and run

alt + shift + f9 select configuration and debug

shift + f10 run

shift + f9 debug

ctrl + shift + f10 run context configuration from editor

debugging

f8 step over

f7 step into

shift + f7 smart step into

shift + f8 step out

alt + f9 run to cursor

alt + f8 evaluate expression

f9 resume program

ctrl + f8 toggle breakpoint

ctrl + shift + f8 view breakpoints

二 idea和eclipse的差別   

idea 中 “new project”對應的是eclipse的“workspace”,而“new module”才是建立一個工程;

idea 不會自動編譯和加載class,eclipse是自動的,

idea可以通過mode eclipse插件來實作自動加載和編輯class;

idea 編輯的檔案是自動儲存的,不能設定為手動儲存。

三 idea常用設定

1.改變編輯文本字型大小

file -> settings -> editor colors & fonts -> font -> size

2.用*辨別編輯過的檔案

editor –> editor tabs

在idea中,你需要做以下設定, 這樣被修改的檔案會以*号辨別出來,你可以及時儲存相關的檔案。"mark modifyied tabs with asterisk"

3.顯示行号 

如何顯示行号:settings->editor->appearance标簽項,勾選show line numbers

4.自定義鍵盤快捷方式 

如果預設代碼提示和補全快捷鍵跟輸入法沖突,如何解決:settings->keymap

5.如何讓光标不随意定位 

settings->editor中去掉allow placement of caret after end of line。

繼續閱讀