Giter Site home page Giter Site logo

vim-template's Introduction

Simple Vim templates plugin

Author: Adrian Perez <[email protected]>

This is a simple plugin for Vim that will allow you to have a set of templates for certain file types. It is useful to add boilerplate code like guards in C/C++ headers, or license disclaimers.

Installation

The easiest way to install the plugin is to install it as a bundle:

  1. Get and install pathogen.vim. You can skip this step if you already have it installed.
  2. cd ~/.vim/bundle
  3. git clone git://github.com/aperezdc/vim-templates.git

Updating

In order to update the plugin, go to the its bundle directory and use Git to update it:

  1. cd ~/.vim/bundle/vim-templates
  2. git pull

Usage

There are a number of options to use a template:

  • Create a new file giving it a name. The suffix will be used to determine which template to use. E.g:

    $ vim foo.c
    
  • In a buffer, use :Template foo to load the template that would be loaded for file with suffix foo. E.g. from within Vim:

    :Template c
    

Template search order

The algorithm to search for templates works like this:

  1. A file named =template.<suffix> in the current directory. If not found, goto (2).
  2. Go up a directory and goto (1), if not possible, goto (3).
  3. Try to use the template.<suffix> file supplied with the plugin.

Variables in templates

The following variables will be expanded in templates:

%DAY%, %YEAR%, %MONTH%
Numerical day of the month, year and month.
%DATE%
Date in YYYY-mm-dd format
%TIME%
Time in HH:MM format
%FDATE
Full date (date + time), in YYYY-mm-dd HH:MM format.
%FILE%
File name, without extension.
%FFILE%
File name, with extension.
%EXT%
File extension.
%MAIL%
Current user's e-mail address. May be overriden by defining g:email.
%USER%
Current logged-in user name. May be overriden by defining g:username.
%HOST%
Host name.
%GUARD%
A string with alphanumeric characters and underscores, suitable for use in proprocessor guards for C/C++/Objective-C header files.
%HERE%
Expands to nothing, but ensures that the cursor will be placed in its position after expanding the template.

vim-template's People

Contributors

aperezdc avatar bchallenor avatar raimondi avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.