vimtemplate


Ⅰ. 插件描述

MRU-like simple template management plugin (NO LONGER MAINTAINED)

Ⅱ. 基本信息

创建日期:  2009-04-21
使用用户:  5
Github星:  2
插件作者:  tyru

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'tyru/vimtemplate'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'tyru/vimtemplate'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'tyru/vimtemplate'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/tyru/vimtemplate.vim

Ⅳ. 文档说明

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

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

添加新评论