Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Disable WAI-ARIA attribute support:

let g:html5_aria_attributes_complete = 0

Align attributes on the first attribute (instead of the last) inside HTML tags:

let g:html5_align_on_first_attribute = 1

## Change Log

### Version 0.27
Expand Down
19 changes: 13 additions & 6 deletions indent/html.vim
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ if exists("*HtmlIndent") && !exists('g:force_reload_html')
finish
endif

if !exists('g:html5_align_on_first_attribute')
let g:html5_align_on_first_attribute = 0
endif

" Allow for line continuation below.
let s:cpo_save = &cpo
set cpo-=C
Expand Down Expand Up @@ -913,13 +917,16 @@ func! s:InsideTag(foundHtmlString)
" <tag attr=
" text<tag attr=
" <tag>text</tag>text<tag attr=
" For long lines search for the first match, finding the last match
" gets very slow.
if len(text) < 300
let idx = match(text, '.*\s\zs[_a-zA-Z0-9-]\+="')
let idx = -1
if g:html5_align_on_first_attribute == 0
" For long lines search for the first match, finding the last match
" gets very slow.
if len(text) < 300
let idx = match(text, '.*\s\zs[_a-zA-Z0-9-]\+="')
else
let idx = match(text, '\s\zs[_a-zA-Z0-9-]\+="')
endif
else
let idx = match(text, '\s\zs[_a-zA-Z0-9-]\+="')
endif
if idx == -1
let idx = match(text, '<\w\+\(-\w\+\)*\s\zs\w')
endif
Expand Down