sponsor Vim development Vim logo Vim Book Ad

vimtemplate : MRU-like simple template management plugin

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

created by
tyru
 
script type
utility
 
description
see latest version at http://github.com/tyru/vimtemplate.vim/
and if you know more about template syntax, see my template files in .vim at http://github.com/tyru/dotfiles/

My .vimrc setting:
  let g:vt_template_dir_path = expand("$HOME/.vim/template")
  let g:vt_command = ""
  let g:vt_author = "tyru"
  let g:vt_email = "[email protected]"

  let s:files_tmp = {
      'cppsrc.cpp'    : "cpp",
      'csharp.cs'     : "cs",
      'csrc.c'        : "c",
      'header.h'      : "c",
      'hina.html'     : "html",
      'javasrc.java'  : "java",
      'perl.pl'       : "perl",
      'perlmodule.pm' : "perl",
      'python.py'     : "python",
      'scala.scala'   : "scala",
      'scheme.scm'    : "scheme",
      'vimscript.vim' : "vim"
  \}
  let g:vt_filetype_files = join(map(keys(s:files_tmp), 'v:val . "=" . s:files_tmp[v:val]'), ',')
  unlet s:files_tmp

Usage:
  COMMANDS:
      VimTemplate
          open template files list.

  MAPPING:
      gt
          open template files list.

  GLOBAL VARIABLES:
      g:vt_template_dir_path (default:"$HOME/.vim/template")
          search files in this dir.
          to specify multi-dirs, set paths joined with ",".

      g:vt_command (default:"VimTemplate")
          command name.
          if this is empty string, won't define the command.

      g:vt_mapping (default:"gt")
          mapping.
          if this is empty string, won't define the mapping.

      g:vt_list_buf_height (default:7)
          height of list buffer.
          buffer shows you list of template files.

      g:vt_filetype_files (default: "")
          when you load one of these files or exec :setlocal ft=<filetype>.
          search these files in your g:vt_template_dir_path.
          e.g.: "java_template.java=java,cpp_template.cpp=cpp"

      g:vt_author
          expand <%author%> to this value.

      g:vt_email
          expand <%email%> to this value.

  TEMPLATE SYNTAX:
      please open the list buffer
      after naming current buffer by

      :e[dit] filename
      or
      :f[ile] filename

      if you didn't, this script uses template file path.
      and you don't have to delete whitespace in <%%>.
      this plugin also allows both <%filename%> and <% filename %>.


      <%eval:code%>
          will expand into result value of code.

      <%path%>
          will expand into current path.
          same as <%eval:expand('%')%>.

      <%filename%>
          will expand into current file name.
          same as <%eval:expand('%:t')%>.

      <%filename_noext%>
          will expand into current file name without extension.
          same as <%eval:expand('%:t:r')%>.

      <%filename_ext%>
          will expand into current filename's extension.
          same as <%eval:expand('%:e')%>.

      <%filename_camel%>
        will expand into camel case of expand('%:t:r').
        so extension is not added to result.

        e.g.:
            foo-bar.baz => FooBar
            foo_bar.baz => FooBar

      <%filename_snake%>
        will expand into snake case of expand('%:t:r').
        so extension is not added to result.

        e.g.: FooBar.baz => foo_bar

      <%parent_dir%>
          will expand into current file's dir.
          same as <%eval:expand('%:p:h')%>.

      <%author%>
          same as <% eval: g:vt_author %>.

      <%email%>
          same as <% eval: g:vt_email %>.

 
install details
move into your plugin folder.
 

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
vimtemplate.vim 0.0.6 2009-09-13 6.0 tyru
- fix bugs:
    - did not ignore whitespaces in <% ... %>
    - if filename is 'FooBar.baz',
      <%filename_snake%> was expanded to '_foo_bar'.
      now is expanded to 'foo_bar'.
- more speed optimization
- <%filename_camel%> now supports '-' and '_' in filename
- implement <%filename_ext%> as template syntax
vimtemplate.vim 0.0.5 2009-09-11 6.0 tyru speed optimization and fix bugs.
vimtemplate.vim 0.0.4 2009-05-31 6.0 tyru 0.0.4: delete g:vt_files_using_template. and support modeline in template file.
vimtemplate.vim 0.0.3 2009-05-31 6.0 tyru add <%author%>, <%email%>, <%filename_camel%>, <%filename_snake%>
vimtemplate.vim 0.0.2 2009-05-28 6.0 tyru fix bug that vimtemplate won't inline
and delete g:vt_support_command and g:vt_support_mapping.
not to define/map command/mapping.
let g:vt_command/g:vt_mapping be empty.

vimtemplate.vim 0.0.1 2009-04-23 6.0 tyru implement g:vt_files_using_template and its template syntax.
vimtemplate.vim 0.0.0 2009-04-21 6.0 tyru Initial upload
ip used for rating: 142.132.191.50

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