aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-05-21 00:30:20 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-05-21 00:30:20 +1200
commite3de36457ecfc59af00e4f1f517c8835dc9055de (patch)
tree40f2111f58ae7d5036abaf167a777efba6539ddb /vim
parent7c2027b87b2eb0b4186fdc3518196369a92c509c (diff)
downloaddotfiles-e3de36457ecfc59af00e4f1f517c8835dc9055de.tar.gz
Add mappings and function for Markdown headings
Diffstat (limited to 'vim')
-rw-r--r--vim/after/ftplugin/markdown.vim6
-rw-r--r--vim/autoload/markdown.vim6
2 files changed, 12 insertions, 0 deletions
diff --git a/vim/after/ftplugin/markdown.vim b/vim/after/ftplugin/markdown.vim
index 7189a09a..6634924e 100644
--- a/vim/after/ftplugin/markdown.vim
+++ b/vim/after/ftplugin/markdown.vim
@@ -31,3 +31,9 @@ xnoremap <buffer> <expr> <LocalLeader>Q
\ quote#QuoteReformat()
let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>Q'
\ . '|xunmap <buffer> <LocalLeader>Q'
+
+" Autoformat headings
+nnoremap <buffer> <LocalLeader>-
+ \ :<C-U>call markdown#Heading('-')<CR>
+nnoremap <buffer> <LocalLeader>=
+ \ :<C-U>call markdown#Heading('=')<CR>
diff --git a/vim/autoload/markdown.vim b/vim/autoload/markdown.vim
new file mode 100644
index 00000000..34c7bda7
--- /dev/null
+++ b/vim/autoload/markdown.vim
@@ -0,0 +1,6 @@
+" Add an underline under a heading
+function! markdown#Heading(char) abort
+ let heading = getline('.')
+ let underline = repeat(a:char, strlen(heading))
+ call append(line('.'), underline)
+endfunction