Code Monkey home page Code Monkey logo

vim-templates's Introduction

This is a Vim plugin for providing filetype-dependent templates for new files, using a simple but effective mechanism.

Usage

When you start a fresh buffer, setting a filetype on it will load the corresponding template. E.g. open Vim and issue

:setf html

You should find a skeleton HTML file, ready to fill in.

One new command has been added for convenience: it is called :New and takes exactly one argument. It will open a new empty window and set the filetype for it to the argument given.

A handful of templates are included, but the real purpose of the plugin is to allow you to easily create your own.

Options

The templates are only applied to new files, not existing empty files. If you want to setup templates so that they apply to empty files, add the following line to your .vimrc

g:templates_empty_files = 1

Creating templates

Templates are kept in .vim/templates. The template filename must be equal to the filetype. So when you set the filetype of an empty buffer to html, .vim/templates/html will be loaded. It's that simple.

In the templates, you can use a cursorline directive to specify a position for the cursor after loading the template. Such a cursorline works much like a modeline: the word cursor: must appear, followed by one or two numbers and opionally the word del, all separated by whitespace. The first number specifies the line the cursor will be placed in. The second, if present, specifies a column. The optional word del directs the script to remove the cursorline at load time. Take a look at the templates supplied in the package, it should be fairly self-explanatory.

vim-templates's People

Contributors

ap avatar somini avatar

Watchers

 avatar James Cloos avatar Sallai András 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.