Coder Social home page Coder Social logo

whiskeycola / vim-mustache-handlebars Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mustache/vim-mustache-handlebars

0.0 0.0 0.0 80 KB

mustache and handlebars mode for vim

Home Page: mustache.github.io

Vim Script 78.76% Mustache 21.24%

vim-mustache-handlebars's Introduction

mustache and handlebars mode for vim

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) and ae (around element)

This plugin contributes to vim-polyglot language pack.

Note: for compatibility reason #7, we've renamed the repo name from vim-mode to vim-mustache-handlebars.

Install for pathogen

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

Get pathogen.

Install for vundle

Add Plugin '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/start
cd ~/.vim/pack/mustache/start
git 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/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

    {{# _}}
    {{/}}
    
  • {{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 on this vim help link. Learning text objects really speeds up the vim workflow.

In that spirit, this plugin defines 2 text objects:

  • ie a mnemonic for inside 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}}}.
  • ae a mnemonic for around 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 braces
  • die - deletes inside the mustache tag, leaving only curly braces
  • yae - "yanks" the whole mustache tag - with curly braces
  • cie - deletes inside the mustache tag and goes in insert mode

ie and ae text objects are enabled by default. To disable them, put the following in your .vimrc:

let g:mustache_operators = 0

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.

vim-mustache-handlebars's People

Contributors

aalvarado avatar andrewradev avatar chris-morgan avatar chrisburnor avatar dasilvacontin avatar gaelan avatar istro avatar jessieay avatar joshuamabina avatar jsit avatar juvenn avatar ktamas avatar michaeldfallen avatar mrzool avatar mverteuil avatar nono avatar rukbotto avatar sheerun avatar trusktr avatar unixnut 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.