Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noahfrederick/vim-skeleton
Initialize new Vim buffers with file-type-specific templates
https://github.com/noahfrederick/vim-skeleton
neovim plugin templates vim
Last synced: 4 months ago
JSON representation
Initialize new Vim buffers with file-type-specific templates
- Host: GitHub
- URL: https://github.com/noahfrederick/vim-skeleton
- Owner: noahfrederick
- Created: 2013-06-20T16:02:51.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2020-09-08T12:29:36.000Z (about 4 years ago)
- Last Synced: 2024-06-10T02:31:22.331Z (5 months ago)
- Topics: neovim, plugin, templates, vim
- Language: Vim script
- Homepage:
- Size: 48.8 KB
- Stars: 31
- Watchers: 3
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vim-skeleton
Initialize new Vim buffers with file-type-specific templates
[![Build Status][buildimg]](https://travis-ci.org/noahfrederick/vim-skeleton)
## Features
- Automatically populate new buffers with file-type-specific templates
- Include dynamic text in your templates with simple placeholders
- Create custom placeholders that are replaced by functions you define
- Define custom replacements based on file-type
- Define custom templates based on filename and containing directory
- Simple convention-over-configuration design (no configuration required)## Usage
### The BasicsAdd something like the following to `~/.vim/templates/skel.xml`:
```xml
<@BASENAME@>
@CURSOR@
@BASENAME@>
```And when you create a new buffer, e.g., `books.xml`, it will be initialized
with your template:```xml
[cursor is here]
```
It differs from a snippet plug-in in that it is concerned with initializing
new buffers with boilerplate text without any manual intervention such as
triggering a snippet.vim-skeleton stays out of your way: it will never load a template unless the
buffer is empty and is not associated with an existing file on disk. And if you
don't happen to want to use the template for a particular file, hitting undo
(`u`) restores your empty buffer.### Template Precedence
Out of the box, vim-skeleton will attempt to load `.`.
So for example, editing a new buffer with name
`app/controllers/user_controller.rb` will attempt to load `controllers.rb` and
fall back to `skel.rb` if not found. The plug-in can be extended with your own
rules for loading templates and doing your own processing of template files
(such as doing custom substitutions). See `:help skeleton-config` for
details.### Provided Commands
Use the `:SkelEdit[!]` command for quick access to the currently loaded
template file (or a specific template if specified).Use the `:SkelInsert[!]` command to load a specific template or force
insertion of a template when automatic insertion wouldn't normally be
triggered.See `:help skeleton-commands` for details.
## Installation
vim-skeleton is installed just about the same way as any other Vim plug-in.
The only extra step is creating your templates directory and adding templates
to it. By default, vim-skeleton looks in `~/.vim/templates`, but this can be
changed (see `:help skeleton-config`).To get started, try:
mkdir -p ~/.vim/templates
echo "Hello world" > ~/.vim/templates/skel.txt
vim hello.txt## Development
### TestingTests are written for [vspec][vspec], which can be installed via
[vim-flavor][vim-flavor]:bundle install
vim-flavor installThe test suite can then be run via the rake task:
rake test
### Documentation
The documentation in `doc/` is generated from the plug-in source code via
[vimdoc][vimdoc]. Do not edit `doc/skeleton.txt` directly. Refer to the
existing inline documentation as a guide for documenting new code.The help doc can be rebuilt by running:
rake doc
[buildimg]: https://img.shields.io/travis/noahfrederick/vim-skeleton/master.svg
[vspec]: https://github.com/kana/vim-vspec
[vim-flavor]: https://github.com/kana/vim-flavor
[vimdoc]: https://github.com/google/vimdoc