how to use zencoding haml in vim

168 views Asked by At

I am wondering if it is possible to expand shorthand HAML in a Zencoding-like-way in Vim. For instance, I use Vundle in my .vimrc file and have haml plugin installed. So something like :

#main.stuff>h1.title+h2.subtitle+p|haml

Is it possible in Vim to trigger above code to expand to :

#main.stuff
  %h1.title
  %h2.subtitle
  %p
1

There are 1 answers

1
dNitro On BEST ANSWER

For writing zen-coding style in vim there is already a dedicated vim plugin called emmet-vim.

From its documentation:

Emmet currently supports CSS, HTML, XML/XSL and HAML, Slim languages via filters (see |emmet-filter|).

Of course if filetype is haml there is no need to apply filtering. Following expression will also expand to desired snippet of code:

#main.stuff>h1.title+h2.subtitle+p

will expand to:

#main.stuff
  %h1.title
  %h2.subtitle
  %p