IntelliJ中的实时模板
如上所述這里 ,的IntelliJ的現(xiàn)場模板可以讓你輕松地插入預定義的代碼片段到你的源代碼。
我在下面發(fā)布了一些我最常用的模板,到GitHub上模板文件完整列表的鏈接(作為我設置新IntelliJ環(huán)境時的參考)以及將IntelliJ設置文件添加到GitHub所采取的步驟。
 例如,我設置了一個模板,以便可以鍵入test并單擊tab,它將為我插入以下JUnit代碼段: 
這是一種JUnit測試方法,最初將光標放在“ public void”之后,可以鍵入測試名稱。 然后,光標跳到{}之間,準備開始編寫測試。
IntelliJ模板存儲在以下位置的user.xml文件中:
~/Library/Preferences/<product name><version number>/templates例如,對于IntelliJ13,它是
~/Library/Preferences/IntelliJIdea13/templates/user.xml 下面列出了我的一些其他模板,觸發(fā)器以粗體顯示。 
 為了可以在任何IntelliJ(例如工作和家庭)上使用這些模板,我在GitHub的此處檢查了完整的列表。 
之前
@Before public void setup() {$END$ }后
@After public void tearDown() {$END$ }yi
fail("Not yet implemented");聚甲醛
public void $NAME$() {$END$ }主要
public static void main(String[] args){$END$ }我采取的將IntelliJ設置添加到GitHub的步驟
 首先,我在GitHub上通過https://github.com/sabram/IntelliJ設置了一個新倉庫。 
 然后,我遵循了這個StackOverflow帖子中有關如何將現(xiàn)有非空目錄轉換為Git工作目錄的說明 : 
在這一點上,我遇到一個錯誤提示我需要先進行git pull。 但是當我做一個
git pull saIntelliJ我說錯了
You asked to pull from the remote 'saIntelliJ', but did not specify a branch. Because this is not the default configured remote for your current branch, you must specify a branch on the command line.因此,我根據(jù)此發(fā)布內容對.git / config進行了編輯,以包括
[branch "master"] remote = saIntelliJ merge = refs/heads/master然后我就可以
git pull saIntelliJ git push -u saIntelliJ master成功,并且可以繼續(xù)使用git pull和git push,而無需每次都指定存儲庫名稱(saIntelliJ)。
翻譯自: https://www.javacodegeeks.com/2014/04/live-templates-in-intellij.html
總結
以上是生活随笔為你收集整理的IntelliJ中的实时模板的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 电脑桌面壁纸赛车(帅气的赛车壁纸)
 - 下一篇: 电脑打开网页一直闪退(电脑打开网页会闪退