blob: 654f8bd9ea527c95a91c4d0757ea47d30319b7e9 [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= How to add code templates?
:page-layout: wikidev
:page-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqEditorHowToAddCodeTemplates
:description: Apache NetBeans wiki DevFaqEditorHowToAddCodeTemplates
:toc: left
:toc-title:
:page-syntax: true
:page-wikidevsection: _editor_and_edited_files
:page-position: 21
1. Create your template file
[source,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE codetemplates PUBLIC "-//NetBeans//DTD Editor Code Templates settings 1.0//EN" "http://www.netbeans.org/dtds/EditorCodeTemplates-1_0.dtd">
<codetemplates>
<codetemplate abbreviation="hello" xml:space="preserve">
`<![CDATA[Hello ${world}]]>`
<description><![CDATA[Bla bla bla]]></description>
</codetemplate>
</codetemplates>
----
[start=2]
. Register it for the mimetype in the layer.xml
[source,xml]
----
<folder name="Editors">
<folder name="text">
<folder name="x-java">
<folder name="CodeTemplates">
<file name="my-templates.xml" url="my-templates.xml"/>
</folder>
</folder>
</folder>
</folder>
----