intellij注释模板_IntelliJ中的实时模板
intellij注釋模板
如上所述這里 ,的IntelliJ的現(xiàn)場(chǎng)模板可以讓你輕松地插入預(yù)定義的代碼片段到你的源代碼。
我在下面發(fā)布了一些我最常用的模板,鏈接到我在GitHub上的模板文件的完整列表(作為設(shè)置新IntelliJ環(huán)境時(shí)的參考),以及將IntelliJ設(shè)置文件添加到GitHub所采取的步驟。
例如,我設(shè)置了一個(gè)模板,以便可以鍵入test并單擊tab,它將為我插入以下JUnit代碼片段:
這是一種JUnit測(cè)試方法,最初將光標(biāo)放在“ public void”之后,可以鍵入測(cè)試名稱(chēng)。 然后,光標(biāo)跳到{}之間,準(zhǔn)備開(kāi)始編寫(xiě)測(cè)試。
IntelliJ模板存儲(chǔ)在以下位置的user.xml文件中:
~/Library/Preferences/<product name><version number>/templates例如,對(duì)于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設(shè)置添加到GitHub的步驟
首先,我在GitHub上通過(guò)https://github.com/sabram/IntelliJ設(shè)置了一個(gè)新倉(cāng)庫(kù)。
然后,我遵循了這個(gè)StackOverflow帖子中有關(guān)如何將現(xiàn)有非空目錄轉(zhuǎn)換為Git工作目錄的說(shuō)明 :
在這一點(diǎn)上,我遇到一個(gè)錯(cuò)誤,提示我需要先進(jìn)行g(shù)it pull。 但是當(dāng)我做一個(gè)
git pull saIntelliJ我說(shuō)錯(cuò)了
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ā)布內(nèi)容對(duì).git / config進(jìn)行了編輯,以包括
[branch "master"] remote = saIntelliJ merge = refs/heads/master然后我就可以
git pull saIntelliJ git push -u saIntelliJ master成功,并且可以繼續(xù)使用git pull和git push,而無(wú)需每次都指定存儲(chǔ)庫(kù)名稱(chēng)(saIntelliJ)。
翻譯自: https://www.javacodegeeks.com/2014/04/live-templates-in-intellij.html
intellij注釋模板
總結(jié)
以上是生活随笔為你收集整理的intellij注释模板_IntelliJ中的实时模板的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 代沟是什么 什么是代沟
- 下一篇: 无浪费编码