aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-23 23:06:08 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-23 23:06:08 +1200
commit64b0fabd853d0e838bddb9645e92d41413e63e61 (patch)
treed37818718ba53eae369efefb78f11fb7273a834b
parentMerge branch 'release/v6.41.0' into develop (diff)
downloaddotfiles-64b0fabd853d0e838bddb9645e92d41413e63e61.tar.gz
dotfiles-64b0fabd853d0e838bddb9645e92d41413e63e61.zip
Replace existing Markdown heading underlines
-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