Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions ftplugin/html_autoclosetag.vim
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ let s:did_auto_closetag = 1

" Gets the current HTML tag by the cursor.
fun s:GetCurrentTag()
return matchstr(matchstr(getline('.'),
\ '<\zs\(\w\|=\| \|''\|"\)*>\%'.col('.').'c'), '^\a*')
return matchstr(matchstr(getline('.'), '.*<\zs.\+>\%'.col('.').'c'), '^[0-9A-Za-z_\-]*')
endf

" Cleanly return after autocompleting an html/xml tag.
Expand Down Expand Up @@ -59,8 +58,8 @@ fun s:CloseTag()
if line[col] !~ '\w\|<\|>' && !s:InComment()
let tag = s:GetCurrentTag()
" Insert closing tag if tag is not self-closing and has not already
" been closed
if tag != '' && tag !~ '\vimg|input|link|meta|br|hr|area|base|param|dd|dt'
" been closed. http://www.w3.org/TR/html5/syntax.html#void-elements
if tag != '' && tag !~ '\varea|base|br|col|embed|hr|img|input|keygen|link|meta|param|source|track|wbr'
\ && !s:ClosingTag(tag)
let line = substitute(line, '\%'.col.'c', '</'.escape(tag, '/').'>', '')
call setline('.', line)
Expand Down