diff --git a/autoload/vimtex/format.vim b/autoload/vimtex/format.vim index 24656fc..ee5bf5c 100644 --- a/autoload/vimtex/format.vim +++ b/autoload/vimtex/format.vim @@ -17,8 +17,7 @@ function! vimtex#format#init_script() " {{{1 \ '%(\\\[|\$\$)\s*$', \], '|') . ')' - let s:border_end = '\v[^\\]\%' - \ . '|\\%(' . join([ + let s:border_end = '\\%(' . join([ \ '\\\*?', \ 'clear%(double)?page', \ 'linebreak', @@ -102,6 +101,12 @@ function! s:format(top, bottom) " {{{1 continue endif + " Skip all lines with comments + if l:line =~# '\v%(^|[^\\])\%' + let l:mark = l:current - 1 + continue + endif + if l:line =~# s:border_end if l:current < l:mark let l:bottom += s:format_build_lines(l:current+1, l:mark)