Change emmet's leader key in Vim
Asked Answered
L

4

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?

Lechery answered 12/4, 2014 at 17:35 Comment(0)
R
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.

Rambling answered 12/4, 2014 at 19:45 Comment(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 regularlyLechery
O
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>'
Orchestral answered 18/6, 2014 at 1:36 Comment(2)
It is a expand key-binding in emmet, and you can use both <Tab> and <C-Y> to trigger the emmet. more information you can find in the doc of vim-emmet(tab the :help emmet in your vim).Orchestral
Thank you for that explanation. It would be better to edit it into your answer rather than leaving an additional comment.Vanderpool
R
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.

Rambling answered 12/4, 2014 at 19:45 Comment(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 regularlyLechery
P
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.

Piece answered 5/12, 2019 at 15:13 Comment(0)
C
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 \

Conspectus answered 15/8, 2021 at 9:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.