Ⅰ. 插件描述
Smart load template for Vim.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'hotoo/template-vim-better-than-revenge'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'hotoo/template-vim-better-than-revenge'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'hotoo/template-vim-better-than-revenge'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/hotoo/template.vim
Ⅳ. 文档说明
# template.vim
Smart load template file for Vim.
Install
Put plugin/template.vim into $VIM/vimfiles/plugin/ for Windows,
or into .vim/plugin/ for *nix.
Put template/template.* into $VIM/vimfiles/template/ for Windows,
or into .vim/template/ for *nix.
If your vim installed snipMate.vim, append snippets/_.snippet content
to $VIM/snippets/_.snippet for Windows,
or to .vim/snippets/_.snippet for *nix.
Usage
:new file.html
:tabnew file.css
If current buffer has been set filetype, you can use command: :Template to
load template.
If your Vim has installed snipMate plugin, input template<Tab> to smart load
the template(when the buffer has suffix or &filetype).
Optional
g:template_autoload
If you didn't want auto load template every time, let g:template_autoload = 0.
g:template_dir
Set you custom template dir.
g:template_author
author name for template placeholder.
Custom Template
Support following placeholder.
${cursor}- default cursor position.${filename}- get origin file name.${FileName}- file-name to File-Name.${FILENAME}- filename to FILENAME.${date}- today.${datetime}- now.${author}- Needlet g:template_author = "You Name"in your vimrc.
TODO(maybe not)
- 一种文件类型支持多个模板。
类似 snipMate 的 ${1:default text},支持多个占位符使用 <Tab> 跳转。${0} 等同于 ${cursor}
- 问题:作为模板来说是不是有点过度设计了?
- 可能会与 snipMate 等使用 <Tab> 的插件冲突。
- 类似 snipMate 的自定义占位符特性,由用户自定义类似 ${date} 这类占位符,动态计算其值。 -- 百合仙子
FIXME
template.hpp 中防范宏定义重复引入的问题,如果文件名中带有特殊字符会出现 BUG。
- 防范方案 I: 不要使用带有特殊字符的文件名 :)
- 解决方案 II: 实现一个占位符,自动剔除、替换特殊字符。
- 解决方案 III: 也许应该实现由用户自定义占位符的特性?
See Also
- VIM 学习笔记 模板 (Template) - 语虚
- [http://www.vim.org/scripts/script.php?script_id=198 template file loader]
- 使用 vim 的一些 tip - 潘魏增
[QuickTemplate@vim.org](http://www.vim.org/scripts/script.php?script_id=2393)- templates.vim : Load filetype templates for new files
template.vim : Simple and flexible template engine.
[@github](http://github.com/thinca/vim-template)- work problem with pathogen
- templates.vim
- vimplate.vim
- Vimplate Enhanced
- load_template
- autoloadTemplate.vim