Modify or Create Code Templates

When you create a file to add to your project (Create a New File), a template is used for the new file. To change this template, select Tools>Templates and then “Open in Editor” to edit a template. You may also use “Add” or “Duplicate” in this dialog to create new templates.

“New Folder” can be used to create a new folder to hold templates. Be aware that MPLAB X IDE filters out all but Microchip Embedded, Shell Scripts, Makefiles and Other, so files or folders should be created under those folders.

Figure 1. Template Manager

You may set template options by selection Tools>Options (MPLAB X IDE>Preferences for macOS), Editor button, Code Templates tab (as shown below).

An option of note for C code is the “fcom” option. In an Editor window, type “fcom” and then press “Tab” to insert the following text into the source code:

// <editor-fold defaultstate="collapsed" desc="${comment}">
${selection}${cursor}// </editor-fold>

This option allows you to hide/view sections of code.

In the Code Template tab, selecting “fcom” will display “${comment}” in the “Expanded Text” section. Hover over this text to see the full text.

Figure 2. Template Options