aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/markdown.vim
blob: c0818246132f6f0f22dae2e435285b9634c557a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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