6

Is it possible to to change the way you expand emmet code into HTML?

The default is ctrl+y+, and thats about two too many keys for my liking.

In sublime I just enter the emmet code and hit tab and it expands it. Is there a way to have it do this vim?

Jonathan Soifer
  • 2,715
  • 6
  • 27
  • 50
Mark
  • 3,137
  • 4
  • 39
  • 76

4 Answers4

10

Add the expand key-binding below in emmet to your .vimrc. You can use both <Tab> and <C-Y> to trigger emmet. More information can be found in the docs (:help emmet).

let g:user_emmet_expandabbr_key = '<Tab>'
Zach Jensz
  • 3,650
  • 5
  • 15
  • 30
Abruzzi
  • 495
  • 3
  • 9
  • It is a expand key-binding in emmet, and you can use both `` and `` to trigger the emmet. more information you can find in the doc of vim-emmet(tab the `:help emmet` in your vim). – Abruzzi Aug 04 '14 at 07:31
  • Thank you for that explanation. It would be better to edit it into your answer rather than leaving an additional comment. – Stephen Ostermiller Aug 04 '14 at 11:18
4

:help emmet-customize explains how to customize Emmet's mappings. As a "noob", you owe it to yourself to get used to Vim's documentation.

You could add the line below to ~/.vimr/after/ftplugin/html.vim:

inoremap <buffer> <tab> <plug>(emmet-expand-abbr)

However, Emmet has a lot of features accessible via a number of mappings all using the same "leader", <C-y> so I'm not sure it is a good idea to take the direction you want to take.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • 1
    Thanks, unfortunately :help emmet-customize gives me 'Sorry no help for emmet-customize' so I will have to look into that as well. You are probably right about it being a bad idea it just seems like a really awkward chord to do regularly – Mark Apr 12 '14 at 20:54
1

I added to my configuration the following mapping

imap ,, <C-y>,

So for example, if I type div or any other emmet expression, then I just type ,, and it gets completed.

Gianluca Casati
  • 3,303
  • 1
  • 32
  • 20
0

i'm using let g:user_emmet_leader_key='<A-e>'

use some special key (<C-e>, <A-e>...) or vim will wait for a emmet-vim command every time you type , or \