<-- back RSS Feed

Skeletons - insert templates in emacs

I discovered skeletons while studying html-mode a while back. They function similarly to 'yasnippets' but have a couple of differences which I prefer (although I do also have yasnippets installed). You can create a snippet using define-skeleton in your init file like so:

(define-skeleton html-headline-1
  "HTML level 1 headline tags."
  "<h1>" _ "</h1>")
This is taken from the sgml-mode source code. They can then be bound like any other function. The underscore in the skeleton is where the cursor is placed or (and this is the crucial feature for me) where the highlighted text is placed when you run the skeleton.