1. 程式人生 > >Eclipse Code Template 設定

Eclipse Code Template 設定

設定註釋模板的入口: Window->Preference->Java->Code Style->Code Template 然後展開Comments節點就是所有需設定註釋的元素啦。現就每一個元素逐一介紹:


檔案(Files)註釋標籤:

/**   
* @Title: ${file_name} 
* @Package ${package_name} 
* @Description: ${todo}(用一句話描述該檔案做什麼) 
* @author A18ccms A18ccms_gmail_com   
* @date ${date} ${time} 
* @version V1.0   
*/

型別(Types)註釋標籤(類的註釋):

/** 
* @ClassName: ${type_name} 
* @Description: ${todo}(這裡用一句話描述這個類的作用) 
* @author A18ccms a18ccms_gmail_com 
* @date ${date} ${time} 

* ${tags} 
*/

欄位(Fields)註釋標籤:

/** 
* @Fields ${field} : ${todo}(用一句話描述這個變量表示什麼) 
*/ 
建構函式標籤:

/** 
* <p>Title: </p> 
* <p>Description: </p> 
* ${tags} 
*/

方法(Constructor & Methods)標籤:

/** 
* @Title: ${enclosing_method} 
* @Description: ${todo}(這裡用一句話描述這個方法的作用) 
* @param ${tags}    設定檔案 
* @return ${return_type}    返回型別 
* @throws 
*/

覆蓋方法(Overriding Methods)標籤:

/* (非 Javadoc) 
* <p>Title: ${enclosing_method}</p> 
* <p>Description: </p> 
* ${tags} 
* ${see_to_overridden} 
*/

代表方法(Delegate Methods)標籤:

/** 
* ${tags} 
* ${see_to_target} 
*/ 
getter方法標籤:

/** 
* @return ${bare_field_name} 
*/

setter方法標籤:

/** 
* @param ${param} 要設定的 ${bare_field_name} 
*/
例子: 
<?xml version="1.0" encoding="UTF-8"?> 
<templates> 
    <template    
                autoinsert="false"    
                context="constructorcomment_context"    
                deleted="false"    
                description="Comment for created constructors"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" 
                name="constructorcomment"> 
    /**   
     * 建立一個新的例項 ${enclosing_type}.   
     *   
     * ${tags}   
     */   
    </template> 
    <template    
                autoinsert="true"    
                context="settercomment_context" 
                deleted="false"    
                description="Comment for setter method"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.settercomment"    
                name="settercomment"> 
    /**   
     * @param ${param} the ${bare_field_name} to set   
     */   
    </template> 
    <template 
                autoinsert="false"    
                context="methodcomment_context"    
                deleted="false"    
                description="Comment for non-overriding methods"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.methodcomment"    
                name="methodcomment"> 
    /**   
     * 此方法描述的是:   
     * @author: [email protected]   
     * @version: ${date} ${time}   
     */   
    </template> 
    <template    
                autoinsert="true"    
                context="delegatecomment_context"    
                deleted="false"    
                description="Comment for delegate methods"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"    
                name="delegatecomment"> 
    /**   
     * ${tags}   
     * ${see_to_target}   
     */   
    </template> 
    <template 
                autoinsert="false"    
                context="filecomment_context"    
                deleted="false"    
                description="Comment for created Java files"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.filecomment"    
                name="filecomment"> 
    /**   
     * 檔名:${file_name}   
     *   
     * 版本資訊:   
     * 日期:${date}   
     * Copyright 足下 Corporation ${year}    
     * 版權所有   
     *   
     */   
    </template> 
    <template    
                autoinsert="false"    
                context="gettercomment_context"    
                deleted="false"    
                description="Comment for getter method"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.gettercomment"    
                name="gettercomment"> 
    /**   
     * ${bare_field_name}   
     *   
     * @return the ${bare_field_name}   
     * @since   CodingExample Ver(編碼範例檢視) 1.0   
    */   
    </template> 
    <template    
                autoinsert="true"    
                context="overridecomment_context"    
                deleted="false"    
                description="Comment for overriding methods"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.overridecomment"    
                name="overridecomment"> 
    /* (non-Javadoc)   
     * ${see_to_overridden}   
     */   
    </template> 
    <template    
                autoinsert="false"    
                context="fieldcomment_context"    
                deleted="false"    
                description="Comment for fields"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment"    
                name="fieldcomment"> 
    /**   
     * ${field}:${todo}(用一句話描述這個變量表示什麼)   
     *   
     * @since Ver 1.1   
     */   
    </template> 
    <template    
                autoinsert="false"    
                context="typecomment_context"    
                deleted="false"    
                description="Comment for created types"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.typecomment"    
                name="typecomment"> 
    /**   
     * 此類描述的是:   
     * @author: [email protected]   
     * @version: ${date} ${time}    
     */   
    </template> 
</templates> 
<?xml version="1.0" encoding="UTF-8"?> 
<templates> 
    <template 
                autoinsert="false" 
                  context="constructorcomment_context" 
                deleted="false" 
                description="Comment for created constructors" 
                enabled="true" 
                id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" 
                name="constructorcomment"> 
    /** 
     * 建立一個新的例項 ${enclosing_type}. 
     * 
     * ${tags} 
     */ 
    </template> 
    <template 
                autoinsert="true" 
                context="settercomment_context" 
                deleted="false" 
                description="Comment for setter method" 
                enabled="true" 
                id="org.eclipse.jdt.ui.text.codetemplates.settercomment" 
                name="settercomment"> 
    /** 
     * @param ${param} the ${bare_field_name} to set 
     */ 
    </template> 
    <template 
                autoinsert="false" 
                context="methodcomment_context" 
                deleted="false" 
                description="Comment for non-overriding methods" 
                enabled="true" 
                id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" 
                name="methodcomment"> 
    /** 
     * 此方法描述的是: 
     * @author: [email protected] 
     * @version: ${date} ${time} 
     */ 
    </template> 
    <template 
                autoinsert="true" 
                context="delegatecomment_context" 
                deleted="false" 
                description="Comment for delegate methods" 
                enabled="true" 
                id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" 
                name="delegatecomment"> 
    /** 
     * ${tags} 
     * ${see_to_target} 
     */ 
    </template> 
    <template 
                autoinsert="false" 
                context="filecomment_context" 
                deleted="false" 
                description="Comment for created Java files" 
                enabled="true" 
                id="org.eclipse.jdt.ui.text.codetemplates.filecomment" 
                name="filecomment"> 
    /** 
     * 檔名:${file_name} 
     * 
     * 版本資訊: 
     * 日期:${date} 
     * Copyright 足下 Corporation ${year} 
     * 版權所有 
     * 
     */ 
    </template> 
    <template 
                autoinsert="false" 
                context="gettercomment_context" 
                deleted="false" 
                description="Comment for getter method" 
                enabled="true" 
                id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" 
                name="gettercomment"> 
    /** 
     * ${bare_field_name} 
     * 
     * @return the ${bare_field_name} 
     * @since   CodingExample Ver(編碼範例檢視) 1.0 
    */ 
    </template>

    <template 
                autoinsert="true" 
                context="overridecomment_context" 
                deleted="false" 
                description="Comment for overriding methods" 
                enabled="true" 
                id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" 
                name="overridecomment"> 
    /* (non-Javadoc) 
     * ${see_to_overridden} 
     */ 
    </template> 
    <template 
                autoinsert="false" 
                context="fieldcomment_context" 
                deleted="false" 
                description="Comment for fields" 
                enabled="true" 
                id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" 
                name="fieldcomment"> 
    /** 
     * ${field}:${todo}(用一句話描述這個變量表示什麼) 
     * 
     * @since Ver 1.1 
     */ 
    </template> 
    <template 
                autoinsert="false" 
                context="typecomment_context" 
                deleted="false" 
                description="Comment for created types" 
                enabled="true" 
                id="org.eclipse.jdt.ui.text.codetemplates.typecomment" 
                name="typecomment"> 
    /** 
     * 此類描述的是: 
     * @author: [email protected] 
     * @version: ${date} ${time} 
     */ 
    </template> 
</templates>

MyEclipse 6.5 程式碼提示的設定

MyEclipse 選擇 Windows ->Preperences ->General ->keys

找到 word completion的快捷鍵把原alt+/刪掉!//必須

Content Assist 的快捷鍵改成alt+/ 或者你想改的其他快捷鍵

MyEclipse編碼設定

Myeclipse安裝後編碼預設是GB18030,一般推薦用UTF-8。如果在匯入專案後發現亂碼現象,那是編碼設定設定不對。

全域性編碼設定的方法:ToolBar-->Window-->Preferences-->General-->Workspace-->Text file encoding,設定合適的編碼。

區域性編碼設定:在原始碼按右鍵-->General-->Editors-->Test Editors-->Spelling-->Encoding,這裡是設定單個檔案的編碼。

推薦還是使用全域性編碼設定。

MyEclipse設定JSP頁面預設編碼方式:

windows(視窗)-Preferences(首選項)-MyEclipse-Files & Editors-JSP-右側encoding:設定為ISO10646/Unicode(UTF-8)

MyEclipseJava檔案中設定作者、日期等說明:

windows(視窗)-Preferences(首選項)-Java-Code Style(程式碼樣式)-Code Templates(程式碼模版)-右側Comments(註釋)-選擇Types(型別)-點選edit(編輯)-輸入如下資訊

/**
* @包名   ${package_name}
* @檔名 ${file_name}
* @作者   NoureWang
* @建立日期 ${date}
* @版本 V 1.0
*/

點選OK(確定)-選中左側的程式碼樣式-選擇右側複選框(Automatically add Comments for new Methods and types)(自動為新方法和型別添加註釋)-點選Apply(應用)-點選OK(確定)

eclipse裡面有一個spell check的開關,把它關了。具體操作windows->preference->輸入spell

自動提示:具體操作windows->preference->輸入content assist    選擇Java->editor->content assist

Auto activation triggers for Java:後面輸入.abcdefghijklmnopqrstuvwxyz 確定

然後匯出

相關推薦

Eclipse Code Template 設定

設定註釋模板的入口: Window->Preference->Java->Code Style->Code Template 然後展開Comments節點就是所有需設定註釋的元素啦。現就每一個元素逐一介紹: 檔案(Files)註釋標籤: /*

Eclipse MyEclipse Code Template 設定

設定註釋模板的入口: Window->Preference->Java->Code Style->Code Template 然後展開Comments節點就是所有需設定註釋的元素啦。現就每一個元素逐一介紹: 檔案(Files)註釋標籤: /** 

eclipse Code Style設定

Code Style主要包括下面幾個方面。 程式碼清理過程: 進入eclipse選單: Window > Preferences > Java > Code Style > Clean Up,點選介面上方的Import,在彈出框中

關於eclipse的編碼註釋等Code Template設置

auth edi lips files In osi span 公司 TE 啥也不說直接放東西: 首先進入eclipse的preferences裏的java 點擊Insert variable可以自己設置需要的 1. 設置Files:點擊edit, /** *

Java Code Template

ren ret insert contex types pack row lds setter 設置註釋模板的入口:Window->Preference->Java->Code Style->Code Template 然後展開Comments節點就

Eclipse IDE中設定Appium專案

如何在Eclipse IDE中設定Appium專案 在執行第一個Appium Mobile Automation指令碼之前,需要執行以下步驟來在Eclipse中設定Appium專案: 下載GSon jar檔案 下載Selenium WebDriver Java客戶端 將Gs

安裝Eclipse IDE並設定專案

下載Eclipse for Java Developers,將其解壓縮並儲存在任何驅動器上。它完全免費。您可以直接執行'eclipse.exe',因此您無需在系統中安裝Eclipse。在本教程中,我們將瞭解如何在Eclipse中為Appium Mobile Automation安裝Eclipse I

VS Code 使用者設定 解決卡頓問題

{     "git.ignoreLegacyWarning": true,     "editor.fontSize": 12,     "editor.minimap.enabled":      true

VS code設定html5 程式碼片段(vue)

檔案 —> 首選項 —> 使用者程式碼片段,開啟html.json(HTML) 說明:每一行都要用雙引號"引起來,並且用逗號,分隔 ,每個需要顯示出來的雙引號都要用\斜槓轉義 個人使用如下設定 { // Place your snippets for ht

Visual Studio Code設定及外掛同步

Visual Studio Code的設定及外掛同步 使用Visual Studio Code開發有一段時間了,用起來是極其的順手,但是唯獨一點不爽的就是,Visual Studio Code不像Visual Studio 2017那樣可以通過微軟賬號進行多裝置間的設定同步。這就很抓狂了,所以我一開始的做

史上最簡單的Eclipse/Myeclipse修改設定預設編碼格式方法

在開發過程中,我們常會遇到中文亂碼問題,因此我們需要將編碼格式設一致,一般將編碼格式設定為UTF-8格式(根據各自的專案需要設定編碼,一般專案大多用UTF-8編碼)。但是我們新建專案時,發現預設的編碼格式為GBK,那麼應該怎麼修改成UTF-8呢? 1.找到安裝目錄中的eclipse.ini或

Visual Studio Code語言設定

Visual Studio Code語言設定 1、按Ctrl+Shift+P快捷鍵,開啟所有的命令,如下圖所示,輸入Configure會自動出現Configure Display Language 或Configure Language並回車。 2、如下圖所示會出現一個local.js

Windows中DOS編譯的工程匯入Eclipse編譯的設定

接手一個移遠MC20二次開發的工程,是在windows中DOS下編譯的,因為最近在用Eclipse開發,所以匯入進來方便開發管理。下面是操作步驟: File > Import… > Existing Code as Makefile Project 匯入工程到Ecli

自用Eclipse程式碼格式化設定

自用專案中統一Eclipse格式化Java、JavaScript、JSP、HTML程式碼設定 1.Window->Preferences //Java 格式化 2.Java->Code Style->Formatter->New->Edit->Line W

eclipse自動提示設定以及問題:去除變數自動提示(圖文詳解)

原文:https://blog.csdn.net/qq_34114951/article/details/76946320   第一件事 eclipse設定為自動提示 配置步驟: 1 Window > Preferences > Java > Editor &

Eclipse常用便捷設定

1、程式碼自動提示   在我們忘記方法名或者想偷懶時,程式碼自動提示很管用。不過Eclipse預設是輸入"."後才會出現包或類成員的提示,也就意味著我們必須先輸入一個完整的類名,提示才能出來;或者每次都按下 alt + / 。如何才能讓它每次只要輸入字母之後,也能出現提示呢

自動程式碼生成的Java Code Template

1. Template設定         Eclipse工具欄上選擇 Window -> Preferences ->  Java  -> Editor -> Templa

Eclipse Code Formatter在IDEA中配置

硬碟安裝:Setting =>Plugins=>Install plugin from disk,選中下載前往下載好的安裝包【EclipseFormatter.zip】安裝,重啟後生效; 選擇Setting => Eclipse Code Format

eclipse的常用設定(空間新建後需要的配置)

地址:https://blog.csdn.net/qiaorui_/article/details/78424491   說明:              新下載的e

eclipse自定義設定製表符為4個空格,設定格式化程式碼換行長度

因製表符在每個開發者工具或檔案編輯器可能格式不一致,這樣很可能造成本身開發工具格式程式碼很規整,到其他工具開啟後可能就會很亂,那麼需要把製表符自定義為幾個空格: window-preference進入設定介面 然後各種應用確定就可以了。 當我們formatter程式碼時