Imaps.vim is a project mainly written in Vim Script, it's free.
another template or stub expander
This is a mirror of http://www.vim.org/scripts/script.php?script_id=244
imaps.vim is yet another template expander or Stubs expander like several others out there.
The expander works by the user pressing '' (or whatever the leader character is), after a "keyword". the keywords are filetype specific. to give an example, suppose you press '' after the word 'bfg' in a latex file (filetype = tex), then the word 'bfg' will expand to:
egin{figure}[h] centerline{psfig{figure=*.eps}} caption{} label{fig:} end{figure}
and the cursor will be placed where '*' is shown. vim remains in insert mode so that you can continue typing. if you type '' after something which is not defined as a keyword for the current filetype, then you will simply get a ''.
the file already contains several mappings mainly for latex and some for html. however it should be very easy to extend it to your liking. it should be fairly obvious how to extend it if you look at the file, but here's the little description:
suppose you want the keyword 'bit' to expand to
egin{itemize} item * end{itemize}
and have the cursor be positioned where '*' is shown, add the following line to imaps.vim (actually, this line is already there, but it makes for a good example)
let s:tex_bit = "egin{itemize}
explanation:
NOTE:
if you want a "dynamic" rhs, i.e you want the keyword 'date' to expand
to the present date, then you can have the rhs begin with the string
"
let s:_date = "
(":help i_CTRL-R" for how this works).
if you want a keyword to be filetype insensetive (i.e to work across all files) like the date thing above, then like the example above, do not prepend any file type, just use
let s:_keyword = expansion
(note the leading underscore after s:)