sponsor Vim development Vim logo Vim Book Ad

expander.vim : flexible expansion of abbreviations/templates

 script karma  Rating 0/0, Downloaded by 621  Comments, bugs, improvements  Vim wiki

created by
Michael Benfield
 
script type
utility
 
description
expander.vim requires Vim's Python interface-----

expander expands abbreviations. Its abbreviations can take arguments that are repeated in the expanded text. For instance, for C++ iterators you can type:

@fib@vector<char>@vec<C-e>

and this expands to:

for(vector<char>::iterator i = vec.begin(); i != vec.end(); ++i) {
    *
}

With your cursor in the place of the *. Defining new abbreviations is easy. The above one was defined like this:

"fib": """
for($1::iterator i = $2.begin(); i != $2.end(); ++i) {
$#$0
}"""

When expander expands this, it replaces the string $# with spaces equal to your shiftwidth, it puts the cursor at $0, and it replaces $1, $2, etc, with the first, second, etc, arguments.
 
install details
Untar expander.tar.bz2 in your ~/.vim so that expander.vim goes into plugin/ and expander.txt goes into doc/. Run :helptags ~/.vim/doc.
:help expander
 

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
expander.tar.bz2 1 2005-01-30 6.0 Michael Benfield Initial upload
ip used for rating: 216.73.216.169

Questions about Vim should go to the maillist. Help Uganda.     Vim at Github