IMAPS is a Vim plugin that expands templates or stubs, allowing users to quickly populate code structures.
\begin{figure}[h]
\centerline{\psfig{figure=*.eps}}
\caption{}
\label{fig:}
\end{figure}
The cursor will be placed where the ‘*’ is shown, allowing the user to continue typing in insert mode. If you type the leader character after something which is not a defined keyword for the current file type, then you get a regular insertion.
imaps.vim already includes different mappings specifically for LaTeX and HTML. However, it is also relatively easy to customize and extend to your preferred format. To do this, you can simply look at the file and follow these simple instructions:
Suppose you want the keyword ‘bit’ to expand to:
\begin{itemize}
\item
\end{itemize}
And have the cursor positioned where ‘*’ is shown. Then, add the following line to imaps.vim:
let s:tex_bit = “\begin{itemize}\item ä\end{itemize}”
The following is an explanation of the different parameters used in the line above:
1) The ‘s’ prefix is used to make it script-specific.
2) ‘Tex’ specifies that ‘deg’ is only treated as a keyword for specific LaTeX files.
3) ‘Bit’ is the keyword itself.
4) The rhs specifies what you want ‘bit’ to expand to. If you want the cursor not to be placed anywhere, then you do not need to do anything. If you want the cursor to be placed in a specific location, however, you can indicate the location using the ä character. This character is obtained by typing control-k-a-colon + a + :,
It is important to note that dynamic rhs can also be used with imaps.vim. For instance, if you want the keyword ‘date’ to expand to the present date, you can use the “=strftime('%b %d %Y')” string in the rhs. You can also assign keywords to be filetype insensitive, similar to the example above, without appending a file type or using s: before the keyword.
IMaps.vim is a powerful tool that requires Vim but is incredibly useful in helping you work faster and with more precision on a daily basis.
Version 1.0: N/A