sponsor Vim development Vim logo Vim Book Ad

vimtemplate : MRU-like simple template management plugin

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

created by
script type
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 = "tyru.exe@gmail.com"

  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

          open template files list.

          open template files list.

      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")
          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"

          expand <%author%> to this value.

          expand <%email%> to this value.

      please open the list buffer
      after naming current buffer by

      :e[dit] filename
      :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 %>.

          will expand into result value of code.

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

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

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

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

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

            foo-bar.baz => FooBar
            foo_bar.baz => FooBar

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

        e.g.: FooBar.baz => foo_bar

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

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

          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:

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.