Skip to content

newwayy/template.vim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

If your vim installed snipMate.vim plugin, input template<Tab> to smart load the template(when the buffer has suffix or &filetype).

Optional

If you didn't want auto load template every time, let g:template_autoload = 0.

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} - Need let g:template_author = "You Name" in your vimrc.

TODO(maybe not)

  • 更流畅的支持 Makefile 这类无后缀的文件。
  • 一种文件类型支持多个模板。
  • 类似 snipMate 的 ${1:default text},支持多个占位符使用 跳转。${0} 等同于 ${cursor}
    • 问题:作为模板来说是不是有点过度设计了?
    • 可能会与 snipMate 等使用 的插件冲突。
  • 类似 snipMate 的自定义占位符特性,由用户自定义类似 ${date} 这类占位符,动态计算其值。 -- 百合仙子

FIXME

  • template.hpp 中防范宏定义重复引入的问题,如果文件名中带有特殊字符会出现 BUG。
    • 防范方案 I: 不要使用带有特殊字符的文件名 :)
    • 解决方案 II: 实现一个占位符,自动剔除、替换特殊字符。
    • 解决方案 III: 也许应该实现由用户自定义占位符的特性?

See Also

About

Smart load template for Vim.

Resources

Stars

Watchers

Forks

Packages