-
Notifications
You must be signed in to change notification settings - Fork 5
/
html.kak
24 lines (21 loc) · 821 Bytes
/
html.kak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
define-command -hidden html-auto-close-tag %{
evaluate-commands -draft -itersel -save-regs '"^' %{
try %{
# Check if last entered characters are "</"
execute-keys -draft hH<a-k><lt><ret>
# Get tag
execute-keys -save-regs '' Z[
execute-keys -with-maps t
execute-keys -save-regs '' ey
# Paste tag
execute-keys -save-regs '' zh<a-p>
# Close tag
execute-keys -with-hooks a<gt>
}
}
}
hook global WinSetOption filetype=(xml|html|php|svelte) %{
# Credits to mawww for this mapping
map -docstring "xml tag object" global object t %{c<lt>([\w.]+)\b[^>]*?(?<lt>!/)>,<lt>/([\w.]+)\b[^>]*?(?<lt>!/)><ret>}
hook -group "close-tag" window InsertChar '/' html-auto-close-tag
}