CategoryTemplates

This page is about emacs packages that does templates or auto-insertions of predefined text. For example, features that lets you automatically insert code templates, such as copyright notice header, HTML header or DTD, timestamps, Java class templates, function syntax skeletons, POV-ray scene files, etc.

Full Featured Generic Template Systems

There are several packages with full featured template systems. A full featured template system will allow you to jump thru fields (e.g. pressing tab to go thru function parameter slots), let parts of the template be variables (such as timestamp in header file), context sensitive expansion (such as not expanding when in inside code comment or string), or let your template contain arbitrary lisp code that eval upon expansion.

Overall, emacs templates packages can be divided into those whose syntax for defining templates is based on plain text, or those based on elisp macro.

Plain Text Based Template Systems

Elisp Macro Based Template Systems

Others

Language Specific Ad Hoc Templates

There are also emacs templates packages written by various people over the years, not based on the above generic template system but are written ad hoc for specific languages.

Here are other packages that do things similar to templates.

Abbreviated Word Expansion

The simplest template-like feature expansion of abbreviations. For example, you can define “elisp” and have it automatically expand to “Emacs Lisp”, or “fsf” expand to “Free Software Foundation”.

Discussions

I find SkeletonMode hard to read and write for longer templates; TempoMode seems to be much easier to use. – AlexSchroeder

I think lisp code based template system is of limited use. They mostly seem early efforts at template. Further, when templates gets complex to a point, best is to simply code elisp. Text based one is the way to go, since it requires no lisp knowldege, so its users can be much broader. In particular, i think recent developement borrowed from TextMate, namely Snippet.el created in 2005, is good. Some info indicates that author of Snippet is no longer maintaining it. Since YaSnippetMode is a rewrite with more features, i think that is the best choice. It has full website support and forum and is active. – Xah Lee

I find yasnippet to be very useful and flexible, for small code-gen, snippet expansions. Type f o r TAB and you get a for loop with fields you can fill in. Very nice. I also like defaultcontent.el for initially filling a newly-created file with boilerplate. My content templates include header comments, license notes, and basic structure. I use both of these packages together. - DinoChiesa

How does TempoMode differ from MsfAbbrev ? Hum well, I see the differences but how does it compare in a day-to-day usage ? – XavierMaillard