Vimplate Enhanced : Vimplate template system for vim 7.0 (supports C/C++/Cpp, Perl, make, LaTeX)
script karma |
Rating 78/24,
Downloaded by 1404 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Jai Tkker |
|
script type |
utility |
|
description |
*** Introduction and Explanation ***
I have made substantial updates to the package layout and installation procedure of Stotz's most recent version of vimplate (v0.2.3). I implemented several fixes so that it would actually be compatible with windows. I have reworked the installation procedure and it should now be much easier to follow.
This version of Vimplate should be MUCH easier to install! (on all operating systems, but especially windows).
It is a really neat plugin and I am very pleased to have it working on my laptop. I hope this will be helpful for at least a few of you out there.
--------------------------------------------------------------------------------
Changelog
--------------------------------------------------------------------------------
0.2.4, released by JET on 2007-02-25
Fixed a number of typos and added additional details in the installation instructions to improve the clarity.
Added prompts during the -createconfig phase of the setup so that the user will not need to do as much editing of the .vimplaterc file by hand.
Added a createconf batch file to simplify things for windows.
Changed how error conditions are handled and displayed in the perl script so that an appropriate amount of information about the problem will be shown.
--------------------------------------------------------------------------------
1. Description
2. Usage
3. Subroutines
4. Example
5. Documentation
6. Depends
7. Installation
1. Description *vimplate-description*
Vimplate provides an extensible and powerful template processing system.
It is based on Perl and Template-Toolkit.
You can create templates for program code, makefiles, letters, html pages,
latex etc. As example vimplate contains templates for C++, LaTeX, Perl
and Makefile.
With vimplate you can write templates which interact with the user.
For themes are the functions choice() and input().
You can choose different locale for the function date() and locale().
You can write your own perl code directly in the templates.
If you find this useful and want to let the original author of this package know, email him at <stotz@gmx.ch>.
If you write a new template and would like me to add it to the vimplate package please send an email with the text [VIMPLATE] in the subject line to: < outtatime@gmail.com >.
2. Usage *vimplate-usage*
Usage:
:Vimplate <template> [options]
choice <template> whit <TAB> (command line completion is supported).
With <TAB> all templates are listed.
[options]
-user|u=<username>
Use the information form user <username> while parsing templates.
-dir|d=<templatedir>
Search templatefiles in <templatedir>.
3. Subroutines *vimplate-subroutines*
locale() for locale please see: man locale
[% loc=locale() %] get the current locale
and write it to the variable loc
[% locale('C') %] set global the current locale to C
[% locale('de_DE') %] set global the current locale to de_DE
date() for date please see: man date
[% date('%c') %] print the current date
with the current locale setting
[% date('de_DE', '%c') %] print the current date with the locale de_DE
input()
[% var=input() %] read input from user
and write it to the variable var
choice()
[% day=choice('day:', 'Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa') %]
let the user choice between different values
and write it to the variable day
please try :Vimplate Test
4. Example *vimplate-example*
a LaTeX Template:
http://www.napali.ch/vimplate/example/LaTeX.tt.html
the generated LaTeX File:
http://www.napali.ch/vimplate/example/Example.tex.html
a Makefile Template for LaTeX:
http://www.napali.ch/vimplate/example/Makefile-LaTeX.tt.html
the generated Makefile:
http://www.napali.ch/vimplate/example/Makefile.html
c++ Templates:
http://www.napali.ch/vimplate/example/hpp-default.tt.html
http://www.napali.ch/vimplate/example/cpp-default.tt.html
the generated class:
http://www.napali.ch/vimplate/example/Example.hpp.html
http://www.napali.ch/vimplate/example/Example.cpp.html
the generated class with doxygen:
http://www.napali.ch/vimplate/example/ExampleDoxy.hpp.html
http://www.napali.ch/vimplate/example/ExampleDoxy.cpp.html
a perl Template:
http://www.napali.ch/vimplate/example/perl.tt.html
the genereated program:
http://www.napali.ch/vimplate/example/Example.pl.html
the genereated program with Log4Perl:
http://www.napali.ch/vimplate/example/ExampleLog.pl.html
Example:
the template letter.tt:
________________________________________________________
[%
sex=choice('sex: ', 'female', 'male')
name=input('name: ')
location=input('your location: ')
-%]
[% ucfirst(location) %], [% date('C', '%b %d, %Y') %]
Dear [% IF sex=='female'; 'Ms'; ELSE; 'Mr'; END %] [% ucfirst(name) %]
...
Sincerely
[% user.firstname %] [% user.lastname %]
________________________________________________________
run vim:
:Vimplate letter
sex:
0) female
1) male
0
name: Meier
your location: Olten
your input was:
:Vimplate letter<CR>0<CR>Meier<CR>Olten<CR>
this will produce this letter:
________________________________________________________
Olten, Jul 11, 2005
Dear Ms Meier
...
Sincerely
Urs Stotz
________________________________________________________
Example:
the template hpp-default.tt:
________________________________________________________
[% classname=input('Class name: ')
doxygen=choice('with Doxygen comments: ', 'no', 'yes')
-%]
#ifndef [% uc(classname) %]_HPP
#define [% uc(classname) %]_HPP
[% IF doxygen=='yes' -%]
/**
* @brief [% classname %] ... short description ...
* @author [% user.firstname %] [% user.lastname %] <[% user.mail %]>
* @date [% date('%Y-%m-%d') %]
* ... description ...
*/
[% END -%]
class [% classname %]
{
public:
[% IF doxygen=='yes' -%]
/**
* Default constructor
*/
[% END -%]
[% classname %]();
[% IF doxygen=='yes' -%]
/**
* Copy constructor
* @param other reference on object to copy
*/
[% END -%]
[% classname %](const [% classname %]& other);
[% IF doxygen=='yes' -%]
/**
* Assignment operator
* @param other reference on object to copy
* @return reference on initialisated object
*/
[% END -%]
[% classname %]& operator=(const [% classname %]& other);
[% IF doxygen=='yes' -%]
/**
* Destructor
*/
[% END -%]
virtual ~[% classname %]();
private:
[% IF doxygen=='yes' -%]
/**
* Base initialisation should be called
* at beginning of each constructor
*/
[% END -%]
void init();
[% IF doxygen=='yes' -%]
/**
* Method to copy each member (deep copy)
* @param other reference on object to copy
*/
[% END -%]
void init(const [% classname %]& other);
};
#endif /* #ifndef [% uc(classname) %]_HPP */
________________________________________________________
run vim:
:Vimplate hpp-default
Class name: Parent
with Doxygen comments:
0) no
1) yes
1
your input was:
:Vimplate hpp-default<CR>Parent<CR>1<CR>
this will produce this c++ include file:
________________________________________________________
#ifndef PARENT_HPP
#define PARENT_HPP
/**
* @brief Parent ... short description ...
* @author Urs Stotz <stotz@gmx.ch>
* @date 2005-07-18
* ... description ...
*/
class Parent
{
public:
/**
* Default constructor
*/
Parent();
/**
* Copy constructor
* @param other reference on object to copy
*/
Parent(const Parent& other);
/**
* Assignment operator
* @param other reference on object to copy
* @return reference on initialisated object
*/
Parent& operator=(const Parent& other);
/**
* Destructor
*/
virtual ~Parent();
private:
/**
* Base initialisation should be called
* at beginning of each constructor
*/
void init();
/**
* Method to copy each member (deep copy)
* @param other reference on object to copy
*/
void init(const Parent& other);
};
#endif /* #ifndef PARENT_HPP */
________________________________________________________
5. Documentation *vimplate-documentation*
Documentation:
- http://napali.ch/vimplate
- http://www.template-toolkit.org/docs.html
- http://perldoc.perl.org/perl.html
Todo:
- better exception handling
- write more templates
License:
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as published
by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
A copy of the GNU GPL is available as /usr/share/common-licenses/GPL-2
on Debian systems, or on the World Wide Web at
http://www.gnu.org/copyleft/gpl.html
You can also obtain it by writing to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Copyright:
Copyright (c) 2005, Urs Stotz <stotz@gmx.ch>
Version:
vimplate 0.2.4 |
|
install details |
6. Depends: *vimplate-depends*
Perl
http://www.perl.org
Windows users:
http://www.activestate.com/Products/ActivePerl
Template-Toolkit
http://search.cpan.org/~abw/Template-Toolkit-2.14
or apt-get install libtemplate-perl
or perl -MCPAN -e"install Template"
Windows users:
ppm install
http://openinteract.sourceforge.net/ppmpackages/AppConfig.ppd
ppm install
http://openinteract.sourceforge.net/ppmpackages/Template-Toolkit.ppd
Suggests:
TT2 syntax:
http://www.vim.org/scripts/script.php?script_id=830
7. Installation *vimplate-installation*
Installation steps:
------------------------
1. change to your $HOME/.vim directory
(on windows: set the variable HOME to "C:\Documents and Settings\<Insert Your User Here>").
2. Move vimplate.zip into your $HOME/.vim folder and extract vimplate.zip there (on windows this folder is '%HOME%\vimfiles').
3. edit your $HOME/.vimrc (or %HOME%\.vimrc on windows) and set the variable Vimplate to the filepath to vimplate.pl
On *nix, this should be the relative path to the vimplate.pl file. For example:
let Vimplate = "~/.vim/vimplate.pl"
On windows, you have to use the full path. If it has spaces in it you need to put escaped quotation marks around the entire value or it will not work. For example, if my user name in Windows is "Villanous Victor", I would add:
let Vimplate = "\"C:/Documents and Settings/Villanous Victor/vimfiles/vimplate.cmd\""
- or -
let Vimplate = "\"C:\\Documents and Settings\\Villanous Victor\\vimfiles\\vimplate.cmd\""
(take note of the double slashing)
6. Run the appropriate command for your operating system to create the $HOME/.vimplaterc (or %HOME%/.vimplaterc on windows) configuration file.
On *nix, run `$HOME/.vim/vimplate.pl -createconfig` to create your configuration file.
On windows you can simple execute the file '%HOME%/vimfiles/vimplate_createconfig.cmd' to initiate the configuration.
7. edit your $HOME/.vimplaterc
(on windows: %HOMEPATH%/.vimplaterc)
8. Fire up vim and perform the appropriate helptag update command for your OS:
*nix: :helptags ~/.vim/doc
windows: :helptags ~/vimfiles/doc
9. Happy Vimplating! Please direct your questions and complaints to < outtatime@gmail.com > and I will do my best to respond in a timely manner.
|
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 18.222.213.240
|