Intellij IDEA提示

來源:互聯網
上載者:User

標籤:intellij idea

代碼自動補全(live templates)IDEA中代碼自動補全

在IDEA中通過”快速鍵+TAB”實現代碼自動補全。
比如System.out.println(“”);,在IDEA中可以sout + TAB實現。

常用代碼自動補全快速鍵
快速鍵 說明
sout System.out.println(“”);
psvm main方法
編寫自己的live templates

1.開啟Live Templates,點擊+建立live template或live template分組,我這裡建立了一個名為tag的live template在名為My Live Template的分組裡。

2.IDEA提供了相關運算式可以實現某些操作,點擊Edit variables編輯模板變數,在Expression中調用相關運算式。
比如,我在模板中定義了一個NAME模板變數($NAME$),點擊Edit variables就可以看到這個變數,在Expression中調用了className()返回當前類的類名。


live templates運算式參考文檔地址:https://www.jetbrains.com/idea/help/creating-and-editing-template-variables.html

3.在live template上右鍵選擇Change context可以定義該live templates可以在哪些語言中使用

4.使用自訂live template

常用設定項常用快速鍵
快速鍵 說明
Alt + Ctrl + S 開啟Settings
Alt + Enter 快速修複
Alt + / 代碼自動補全
Ctrl + Shift + i 根據當前上下文顯示代碼定義,比如:游標停在方法上就會以popupview方式顯示該方法的定義
Ctrl + click 跳到源碼
Shift + Shift 搜尋所有檔案
Ctrl + E 開啟最近訪問檔案清單
設定Eclipse風格快速鍵

使用黑色風格主題

預設顯示行號

設定檔案編碼預設為UTF-8

字型設定

開啟Font,點擊Save As建立自訂的字型配置,Size設定為16會比較好看。

代碼快速註解的使用

預設Fix doc comment是沒有設定快速鍵的,我這裡把他設定成Ctrl + Alt + M

在方法名稱、類名、欄位名上按Ctrl + Alt + M,會自動加上註解模板內容

匯出工程到Eclipse


匯出成功後,在工程目錄下會自動添加Eclipse工程相關設定檔,然後就可以使用Eclipse開啟該工程了。

自訂檔案和代碼模板

1.開啟File and Code Templates,點擊+添加自己的模板,模板的編寫可參考現有模板。
說明文檔地址:https://www.jetbrains.com/idea/help/creating-and-editing-file-templates.html

2.模板設定完成後,就可以在New的時候使用自訂的模板了

模板檔案就放在使用者目錄下
- Windows: <your home directory>\.<product name><version number>\config\templates
- Linux: ~/.<product name><version number>/config/templates
- OS X: ~/Library/Preferences/<product name><version number>/templates

關聯api文檔

1.開啟Project Structure(Ctrl+Shift+Alt+S),在這裡可以關聯Module、Libraries、SDK的文檔,點擊+關聯文檔,有兩個+:一個是關聯本地文檔,一個是關聯線上文檔

2.關聯成功後,在游標停在類名時按下Shift + F2即可開啟該類的api doc。

intellij idea參考手冊地址:https://www.jetbrains.com/idea/help/intellij-idea.html

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

Intellij IDEA提示

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.