sponsor Vim development Vim logo Vim Book Ad

Advancer Abbreviation : create code snippet through vim abbreviation

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

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

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

Usage
-----
    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.

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

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

Tutorial
--------
###Preparation
    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

1

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

2

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

    |

Write Your Own Abbreviation
---------------------------
    Use Command Abbr
    Usage: Abbr [name] [code]
    Example:
    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: 18.222.10.9

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.
   
Vim at Github