Ⅰ. 插件描述
spacebars, mustache and handlebars mode for vimⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'slava/vim-spacebars'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'slava/vim-spacebars'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'slava/vim-spacebars'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/slava/vim-spacebars
Ⅳ. 文档说明
spacebars and mustache and handlebars mode for vim
This is a fork of [vim-mustache-handlebars] adapted for [Spacebars]. In addition
to the corrected syntax this fork also has folds defined and the correct
indentation is in plans.

The Readme of the original is following. For installation details, be sure to
use the git-url of this fork (git://github.com/Slava/vim-spacebars.git) and
the name Slava/vim-spacebars if you use Bundle/NeoBundle/Vundle.
- *
A vim plugin for working with mustache and
handlebars templates. It has:
- syntax highlighting
- matchit support
- mustache abbreviations (optional)
- section movement mappings
[[and]] - text objects
ie(inside element) andae(around element)
Note: for compatibility reason #7, we've renamed the repo name fromvim-mode to vim-mustache-handlebars.
Install for pathogen
cd ~/.vim/
git submodule add git://github.com/mustache/vim-mustache-handlebars.git bundle/mustache
vim bundle/mustache/example.mustache
Get pathogen.
Install for vundle
Add Bundle 'mustache/vim-mustache-handlebars' to your .vimrc and do a :BundleInstall.
Manually Install
cd ~/.local/src
git clone git://github.com/mustache/vim-mustache-handlebars.git mustache.vim
cp -R mustache.vim/syntax/* ~/.vim/syntax/
cp -R mustache.vim/ftdetect/* ~/.vim/ftdetect/
cp -R mustache.vim/ftplugin/* ~/.vim/ftplugin/
vim mustache.vim/example.mustache
Mustache Abbreviations
You can activate mustache abbreviations by putting this line in your .vimrc:let g:mustache_abbreviations = 1
Now you get a set of convenient abbreviations. Underscore _ indicates where
your cursor ends up after typing an abbreviation:
{{=>{{_}}{{{=>{{{_}}}{{!=>{{!_}}{{>=>{{>_}}{{<=>{{<_}}{{#produces{{# _}} {{/}}{{ifproduces{{#if _}} {{/if}}{{ifeproduces{{#if _}} {{else}} {{/if}}
Section movement mappings
Following the vim convention of jumping from section to section, [[ and ]]
mappings are implemented for easier movement between mustache tags.
]]jumps to the first following tag[[jumps to the first previous tag
Count with section movements is supported:
2]]jumps to the second next tag
Text objects
Vim has a very powerful concept of "text objects". If you aren't using text objects,
you can get familiar with it on [this vim help
link](http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objects). Learning
text objects really speeds up the vim workflow.
In that spirit, this plugin defines 2 text objects:
iea mnemonic forinside element, selects all the text inside the
mustache tag.
For example, when used with vie it will visually select the
bold text in the following snippets: {{some_variable}},
{{{different_variable}}}.
aea mnemonic foraround element, selects the whole mustache tag,
including the curly braces.
Example, vae visually selects the bold text in the following
snippets: {{some_variable}} or {{{another_variable}}}.
Here are other usage examples:
dae- deletes the whole mustache tag, including the curly bracesdie- deletes *inside the mustache tag, leaving only curly bracesyae- "yanks" the whole mustache tag - with curly bracescie- deletes inside the mustache tag and goes in insert mode
Maintainers
This is combined work from
juvenn/mustache.vim and
nono/vim-handlebars.
Thanks @5long for adding matchit support.
You're encouraged to propose ideas or have discussions via github
issues.