aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vim/autoload/markdown.vim9
1 files changed, 7 insertions, 2 deletions
diff --git a/vim/autoload/markdown.vim b/vim/autoload/markdown.vim
index c0818246..8bac8045 100644
--- a/vim/autoload/markdown.vim
+++ b/vim/autoload/markdown.vim
@@ -11,8 +11,13 @@ function! markdown#Heading(char) abort
" heading text
let underline = repeat(a:char, strlen(heading))
- " Append the heading text to the buffer on a new line after the heading
- call append(pos[1], underline)
+ " If the line after this one looks like it's already an underline, replace
+ " it; otherwise, create a new underline
+ if getline(pos[1] + 1) =~# '^[-=]\{2,}$'
+ call setline(pos[1] + 1, underline)
+ else
+ call append(pos[1], underline)
+ endif
" Move to the first column of the underline we just inserted
let pos[1] += 1