- Notifications
You must be signed in to change notification settings - Fork48
mustache and handlebars mode for vim
mustache/vim-mustache-handlebars
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A vim plugin for working withmustache andhandlebars templates. It has:
- syntax highlighting
- matchit support
- mustache abbreviations (optional)
- section movement mappings
[[and]] - text objects
ie(inside element) andae(around element)
This plugin contributes tovim-polyglot language pack.
Note: for compatibility reason #7, we've renamed the repo name fromvim-mode tovim-mustache-handlebars.
cd ~/.vim/git clone git://github.com/mustache/vim-mustache-handlebars.git bundle/mustachevim bundle/mustache/example.mustacheGetpathogen.
AddPlugin 'mustache/vim-mustache-handlebars' to your.vimrc and do a:PluginInstall.
Heads up! Only available for Vim 8+
mkdir -p ~/.vim/pack/mustache/startcd ~/.vim/pack/mustache/startgit clone https://github.com/mustache/vim-mustache-handlebars.gitTo learn more about Vim's built-in package manager::help packages.
cd ~/.local/srcgit clone git://github.com/mustache/vim-mustache-handlebars.git mustache.vimcp -R mustache.vim/syntax/* ~/.vim/syntax/cp -R mustache.vim/ftdetect/* ~/.vim/ftdetect/cp -R mustache.vim/ftplugin/* ~/.vim/ftplugin/vim mustache.vim/example.mustacheYou 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 whereyour cursor ends up after typing an abbreviation:
{{=>{{_}}{{{=>{{{_}}}{{!=>{{!_}}{{>=>{{>_}}{{<=>{{<_}}{{#produces{{# _}}{{/}}{{ifproduces{{#if _}}{{/if}}{{ifeproduces{{#if _}}{{else}}{{/if}}
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
Vim has a very powerful concept of "text objects". If you aren't using text objects,you can get familiar with it onthis vim helplink. Learningtext 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 themustache tag.For example, when used withvieit will visually select thebold text in the following snippets: {{some_variable}},{{{different_variable}}}.aea mnemonic foraround element, selects the whole mustache tag,including the curly braces.Example,vaevisually selects the bold text in the followingsnippets:{{some_variable}} or{{{another_variable}}}.
Here are other usage examples:
dae- deletes the whole mustache tag, including the curly bracesdie- deletesinside the mustache tag, leaving only curly bracesyae- "yanks" the whole mustache tag - with curly bracescie- deletesinside the mustache tag and goes in insert mode
ie andae text objects are enabled by default. To disable them, put thefollowing in your.vimrc:
let g:mustache_operators = 0This is combined work fromjuvenn/mustache.vim andnono/vim-handlebars.
Thanks@5long for adding matchit support.
You're encouraged to propose ideas or have discussions via githubissues.
About
mustache and handlebars mode for vim
Resources
Uh oh!
There was an error while loading.Please reload this page.