Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

mustache and handlebars mode for vim

NotificationsYou must be signed in to change notification settings

mustache/vim-mustache-handlebars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

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 objectsie (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.

Install for pathogen

cd ~/.vim/git clone git://github.com/mustache/vim-mustache-handlebars.git bundle/mustachevim bundle/mustache/example.mustache

Getpathogen.

Install for vundle

AddPlugin 'mustache/vim-mustache-handlebars' to your.vimrc and do a:PluginInstall.

Built-in Vim Package Manager

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.git

To learn more about Vim's built-in package manager::help packages.

Manually Install

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.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 whereyour cursor ends up after typing an abbreviation:

  • {{ =>{{_}}

  • {{{ =>{{{_}}}

  • {{! =>{{!_}}

  • {{> =>{{>_}}

  • {{< =>{{<_}}

  • {{# produces

    {{# _}}{{/}}
  • {{if produces

    {{#if _}}{{/if}}
  • {{ife produces

    {{#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 onthis vim helplink. Learningtext objects really speeds up the vim workflow.

In that spirit, this plugin defines 2 text objects:

  • ie a mnemonic forinside element, selects all the text inside themustache tag.For example, when used withvie it will visually select thebold text in the following snippets: {{some_variable}},{{{different_variable}}}.
  • ae a mnemonic foraround element, selects the whole mustache tag,including the curly braces.Example,vae visually 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 braces
  • die - deletesinside the mustache tag, leaving only curly braces
  • yae - "yanks" the whole mustache tag - with curly braces
  • cie - 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 = 0

Maintainers

This 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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors25


[8]ページ先頭

©2009-2025 Movatter.jp