sponsor Vim development Vim logo Vim Book Ad

drcstubs : Imaps to provide active stubs  (currently: c, LaTeX, sh, vim)

 script karma  Rating 24/9, Downloaded by 1044    Comments, bugs, improvements  Vim wiki

created by
Charles Campbell
script type
All of the DrCStubs ftplugin scripts provide maps which work during insert mode.  One may use either the shorthand or longhand maps to invoke the corresponding imap.  They are invoked whenever a string is followed by a backquote.

One major advantage of these imaps is that they, in turn, take advantage of the user's cindent settings and/or indentation scripts.  Thus the result should be as if the user had typed them him/herself.

  * These imaps will not operate if "set paste:" is on.
  * They work well with vimscript#1270 indenting scripts

In the maps below:

An "X" is where the cursor will end up after the map is invoked.
An "Y" is where the cursor will end up after an <esc> is pressed.
A  "|" means a newline.

Another form of help is available by typing >


     Shorthand    Longhand     Expands
     Map          Map          To
     ---------    --------     -------
     i`           if`          if(X) {Y}
     e`           els[e]`      else {X}
     ei`          eli[f]`      else if(X) {Y}
     f`           for\=`       for(X;;) {Y}
     w`           wh[ile]`     while(X) {Y}
     s`           sw[itch]`    switch(X) {Y}
     c`           ca[se]`      case X: Y break;
     d`           defa[ult]`   default: Y break;
     `            do`          do {X} while(Y);
     E`           Ed[bg]`      Edbg((\"func(X)\"Y));
     R`           Rd[bg]`      Rdbg((\"funcX\"Y));
     D`           Dp[rintf]`   Dprintf((1,\"X\"Y));
                  in[clude]`   #include X
                  de[fine]`    #define X
                  #`           #ifdef X ... #endif

       Environments And Abbreviations
     Shorthand    Longhand     Expands
     Map          Map          To
     ---------    --------     -------
     align`                    \begin{align}|X|\end{align}
     arr`         array`       \left[\begin{array}{ccc}|X|\end{array}\right]
     ctr`         center`      \begin{center}|X|\end{center}
     desc`        description` \begin{description}|\item[X]|\end{sdescription}
     enum`        enumerate`   \begin{enumerate}|\item X|\end{enumerate}
     eps`         epsf`        \begin{figure}[H]\centering\framebox{\epsfbox{X.eps}}\end{figure}
     eqn`         equation`    \begin{equation}|X|\end{equation}
     eqna`        eqnarray`    \begin{eqnarray}|X&=& Y \\|\end{eqnarray}
     fig`         figure`      \begin{figure}[H]\centering \framebox{X} \caption{CAPTION HERE} \end{figure}
     flalign`                  \begin{flalign}|X|\end{flalign}
     frac`                     \frac{X}{Y}
     gat`         gather`      \begin{gather}|X|\end{gather}
     i`                        \item X
     i`                        \item[X] Y        (if vim v7, and in a description block)
     item`        itemize`     \begin{itemize}|\item X|\end{itemize}
     mat`         matrix`      \left[|\begin{array}{cc}| X &   & \\|&   & |\end{array}|\right]
     mini`        minipage`    \begin{minipage}[H]{4in}|X|\end{minipage}
     multc`       multicol`    \multicolumn{1}{X|c|}{MultiColumn}
     multl`       multline`    \begin{multline}|X|\end{multline}
     split`                    \begin{equation}\begin{split}|X|\end{split}\end{equation}
     tab`         tabular`     (too long for here)
     v`                        \verb`X`
     verb`        verbatim`    \begin{verbatim}|X|\end{verbatim}

         Script Style Support
     Shorthand    Longhand     Expands
     Map          Map          To
     ---------    --------     -------
     bf`                       \textbf{}
     it`                       \textit{}
     rm`                       \textrm{}
     sc`                       \textsc{}
     sf`                       \textsf{}
     sl`                       \textsl{}
     tt`                       \texttt{}
     mtt`                      \mathtt{}
     mrm`                      \mathrm{}
     mbf`                      \mathbf{}
     msf`                      \mathsf{}
     mtt`                      \mathtt{}
     mit`                      \mathit{}
     mcal`                     \mathcal{}

                 Greek Letters:
     Shorthand    Expands        Shorthand    Expands
     Map          To             Map          To
     ---------    -------        ---------    -------
     a`           \alpha        v             \nu
     b`           \beta         f             \xi
     g`           \gamma        p             \pi
     d`           \delta        vp            \varpi
     e`           \epsilon      r             \rho
     ve`          \varepsilon   vr            \varrho
     z`           \zeta         s             \sigma
     n`           \eta          v             \varsigma
     t`           \theta        t             \tau
     vt`          \vartheta     u             \upsilon
     io`          \iota         h             \phi
     k`           \kappa        vh            \varphi
     l`           \lambda       x             \chi
     m`           \mu           q             \psi
     w`           \omega

     Shorthand    Longhand     Expands
     Map          Map          To
     ---------    --------     -------
     ca[se]`      c`           case X in|Y|esac
     fo[r]`       f`           for X in Y ; do|Z|done
     if`          i`           if [[ X ]]; then|Y|fi
     eli[f]`      ei`          elif [[ X ]]; then|Y
     els[e]`      e`           else|X
     fu[nction]`               function X|{|Y|}
     wh[ile]`     w`           while [[ X ]]; do|Y|done

     Shorthand    Longhand     Expands
     Map          Map          To
     ---------    --------     -------
     i            if           if X|endif
     e            els[e]       else|X
     ei           eli[f]       elseif X
                  fu[nction]   fun! X(Y)|endfun
     w            wh[ile]      while X|endwhile
     F            Df[unc]      call Dfunc("func(X)")|Y
     R            Dr[et]       call Dret("return func X")
     D            De[echo]     call Decho("X")|Y

(alpha/beta version available at http://www.drchip.org/astronaut/vim/index.html#DRCSTUBS)
install details
1. Place drcstubs.tar.gz in your $HOME/.vim or ..wherever..\vimfiles directory
2. gunzip drcstubs.tar.gz
3. tar -oxvf drcstubs.tar
4. Have  "filetype plugin indent on" in your <.vimrc>

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
drcstubs.vba.gz 3 2010-04-01 7.0 Charles Campbell New mappings and menu support in stub (template) files for c, sh, tex, and vim
drcstubs.tar.gz 1 2005-05-03 6.0 Charles Campbell Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo