imaps

imaps is a template expander or Stubs expander for Vim.
Download

imaps Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Srinath Avadhanula
  • Publisher web site:
  • http://www.vim.org/scripts/script.php?script_id=244

imaps Tags


imaps Description

imaps is a template expander or Stubs expander for Vim. imaps is a template expander or Stubs expander for Vim.How it works: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:begin{figure}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 tobegin{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}item end{itemize}"Explanation:1. the suffix 's:' is to make it script specific.2. then 'tex' makes imaps.vim treat 'deg' as a keyword only for latex files.3. 'bit' is the keyword itself.4. the rhs is what you want to have 'bit' expand to. if you want the cursor not to be positioned anywhere special, then nothing needs to be done. the cursor will be placed at the end. However, if like in this example, you want it to be at a specific place, put a "" (the a-double-dot character) where you want the cursor to be. (the character is obtained by typing control-k-a-colon + a + : ).NOTE:1. 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 "=". for example, the following line does the date thingie: let s:_date = "=strftime('%b %d %Y')" (":help i_CTRL-R" for how this works).2. 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:) Requirements:· Vim Requirements: · Vim


imaps Related Software