In vim, you can complete open html tags and close tags using omni-completion, invoked via ctrl-xctrl-o. To do this though, you must first type <
or </
depending on which tag you want. For close, the tag corresponding to the nearest unclosed open tag will be chosen, for example:
<div>
<p>asdf</p>
</[] <-- PRESS ctrl-x ctrl-o HERE
This is a little bit inconvenient, so we can make a mapping for close tag:
inoremap <c-b> </<c-x><c-o>
Pressing ctrl-b in insert mode will enter the desired close tag.
This map works, but isn't ideal because it will enter </>
when no close tab is appropriate. We can modify the map to help
inoremap <c-b> <c-\><c-o>a</<c-x><c-o><c-r>=get(v:completed_item, 'word', '>') ==# '>' ? "\<lt>c-u>" : ''<cr>
The idea behind this map is if only >
was inserted, backspace the inserted text. The point of <c-\><c-o>a
is to limit the amount backspaced over with <c-u>
.