sponsor Vim development Vim logo Vim Book Ad

Advancer Abbreviation : create code snippet through vim abbreviation

 script karma  Rating 1/1, Downloaded by 1059  Comments, bugs, improvements  Vim wiki

created by
Miao Jiang
script type
Repository, Tutorial: https://github.com/jiangmiao/advancer-abbreviation

Advancer Abbreviation
Advancer Abbreviation is a Vim plugin to create code snippet quickly

    Use Shortcut <C-CR> or <S-CR> to expand the abbreviation or jump to next placeholder.

    <S-CR> : Smart Expand or jump to next placeholder.
    <C-CR> : Force Expand or jump to next placeholder.
    <ESC>  : If the line contain placeholder but now it is blank,
             then delete whole line and leave insert mode.

*   Support any character except space as abbreviate name.
*   Quick jump to next placeholder.
*   Easy to extend.

    copy plugin/advancer-abbreviate.vim to ~/.vim/plugin

    copy ftplugin-examples/* to ~/.vim/ftplugin

    There are 5 examples include c, cpp, javascript, php, ruby
    The abbreviation supported in example are

        c          : for std main #i #ii
        cpp        : for std main
        javascript : for fu
        ruby       : for def
        php        : for

    You could test the script with your favourite language.

###example for edit C file
    <C-CR> = Control+Return
    |      = Cursor postion
    $ gvim foo.c


    input: #i<C-CR>foo<C-CR>#ii<C-CR>bar<C-CR>
    #include <foo>
    #include "bar"


    input: std<C-CR>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>


Write Your Own Abbreviation
    Use Command Abbr
    Usage: Abbr [name] [code]
    Abbr for for (/*TODO*/; /*TODO*/; /*TODO*/) {<CR>/*TODO*/<CR>}<CR>/*TODO*/
    Abbr #ii #include "/*TODO*/"<CR>

    Abbreviate format is same as vim abbr. see help :abbr
    but AdvAbbr has looser limition on name, it support any character as name except space.
    eg: f.f is invalid name in vim abbr but valid in Advancer Abbreviation.
    TODO has four different formats
    /*TODO*/, #TODO#, 'TODO', <!--TODO-->
    choose them according to which language is using.
    for example, /*TODO*/ use for c, cpp, 'TODO' use for ruby
install details
copy plugin/advancer-abbreviate.vim to ~/.vim/plugin

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
advancer-abbreviation-v1.0.3.tar.gz 1.0.3 2011-06-07 7.0 Miao Jiang Use b:Abbrs instead of g:Abbrs to manage abbrs
update README
advancer-abbreviation-v1.0.2.tar.gz 1.0.2 2011-05-25 7.0 Miao Jiang Add Smart Expand and Force Expand
advancer-abbreviation-v1.0.1.tar.gz 1.0.1 2011-05-24 7.0 Miao Jiang add option g:AbbrShortcutEscape and g:AbbrShortcutExpand
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.
OSDN.net Logo