aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-05-21 00:44:38 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-05-21 00:44:38 +1200
commit40789aade09f3435ee080a234ac8f1da9b0d705b (patch)
treedcf05936cb580f2484072f98c13e0bedfa44f99b
parentEnd heading mapping on first column (diff)
downloaddotfiles-40789aade09f3435ee080a234ac8f1da9b0d705b.tar.gz
dotfiles-40789aade09f3435ee080a234ac8f1da9b0d705b.zip
Add comments to Markdown heading mapping
-rw-r--r--vim/autoload/markdown.vim12
1 files changed, 12 insertions, 0 deletions
diff --git a/vim/autoload/markdown.vim b/vim/autoload/markdown.vim
index 5b4ea205..c0818246 100644
--- a/vim/autoload/markdown.vim
+++ b/vim/autoload/markdown.vim
@@ -1,10 +1,22 @@
" Add an underline under a heading
function! markdown#Heading(char) abort
+
+ " Get current position
let pos = getpos('.')
+
+ " Get heading text from current line
let heading = getline(pos[1])
+
+ " Build underline string by repeating character by the string length of the
+ " 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)
+
+ " Move to the first column of the underline we just inserted
let pos[1] += 1
let pos[2] = 1
call setpos('.', pos)
+
endfunction