Skip to content

Commit 7b9425e

Browse files
committed
Match empty atx headings
1 parent 4455ea6 commit 7b9425e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

ftplugin/markdown.vim

+8-8
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@
4848
" For each level, contains the regexp that matches at that level only.
4949
"
5050
let s:levelRegexpDict = {
51-
\ 1: '\v^(#[^#]@=\s+|.+\n\=+$)',
52-
\ 2: '\v^(##[^#]@=\s+|.+\n-+$)',
53-
\ 3: '\v^###[^#]@=\s+',
54-
\ 4: '\v^####[^#]@=\s+',
55-
\ 5: '\v^#####[^#]@=\s+',
56-
\ 6: '\v^######[^#]@=\s+'
51+
\ 1: '\v^(#\_s@=|.+\n\=+$)',
52+
\ 2: '\v^(##\_s@=|.+\n-+$)',
53+
\ 3: '\v^###\_s@=',
54+
\ 4: '\v^####\_s@=',
55+
\ 5: '\v^#####\_s@=',
56+
\ 6: '\v^######\_s@='
5757
\ }
5858

5959
" Maches any header level of any type.
6060
"
6161
" This could be deduced from `s:levelRegexpDict`, but it is more
6262
" efficient to have a single regexp for this.
6363
"
64-
let s:headersRegexp = '\v^(#{1,6}\s+|.+\n(\=+|-+)$)'
64+
let s:headersRegexp = '\v^(#{1,6}\_s|.+\n(\=+|-+)$)'
6565

6666
" Returns the line number of the first header before `line`, called the
6767
" current header.
@@ -526,7 +526,7 @@ function! s:HeaderDecrease(line1, line2, ...)
526526
let l:numSubstitutions = s:SetexToAtx(a:line1, a:line2)
527527
let l:flags = (&gdefault ? '' : 'g')
528528
for l:level in range(replaceLevels[0], replaceLevels[1], -l:levelDelta)
529-
execute 'silent! ' . a:line1 . ',' . (a:line2 - l:numSubstitutions) . 'substitute/' . s:levelRegexpDict[l:level] . '/' . repeat('#', l:level + l:levelDelta) . ' /' . l:flags
529+
execute 'silent! ' . a:line1 . ',' . (a:line2 - l:numSubstitutions) . 'substitute/' . s:levelRegexpDict[l:level] . '/' . repeat('#', l:level + l:levelDelta) . '/' . l:flags
530530
endfor
531531
endfunction
532532

0 commit comments

Comments
 (0)