vim-templates (vimawesome)

Create files from predefined templates. Templates are files with .template extension.

Installation

Vundle

Plugin 'tibabit/vim-templates'

vim-plug

Plug 'tibabit/vim-templates'

Usage

Using default templates

NOTE: All file names are case sensitive.

Auto initialization

By default auto initialization is set to true, so whenever a new file is created, the file is automatically initialized if a template matches (for file name or file extension, since file name is more specific, it is given priority over file extension). This can be disabled by setting g:tmpl_auto_initialize to 0 in your .vimrc.

Customization

Creating your own templates

h.template

/**
 * @author      :  ()
 * @created     : 
 * @filename    : 
 */
#ifndef 
#define 

/* declarations */

#endif /*  */

generates this for a file named header.h

/**
 * @author      : Vikas Kesarwani (vikash@abc.com)
 * @created     : 07/09/2018
 * @filename    : header
 */

#ifndef HEADER_H
#define HEADER_H

/* declarations */

#endif /* HEADER_H */

Search paths

The plugin searches for templates as follows

  1. In folders named templates recursively up the directory tree, i.e. first in a directory templates under the current working directory, then in ../templates, then ‘../../templates’, …
  2. In search paths defined by g:tmpl_search_paths in your .vimrc file
  3. The templates folder in this plugin’s directory

If you want to add a custom directory to the search path, e.g. if you placed them inside a templates directory under $HOME then add the following line in your .vimrc file:

let g:tmpl_search_paths = ['~/templates']

Configuring the placeholder values

Placeholders

The Following placeholders are currently supported by this plugin

Date & Time

Authoring

File name

Others