Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ftplugin/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@ endfunction
function! s:TableFormat()
let l:pos = getpos('.')

normal! {
call search('|')
let l:start = line('.')
let l:indent = matchstr(getline(l:start), '^\s*')

if get(g:, 'vim_markdown_borderless_table', 0)
" add `|` to the beginning of the line if it isn't present
normal! {
Expand Down Expand Up @@ -575,6 +580,17 @@ function! s:TableFormat()
execute 's/:\( \+\)|/\1:|/e' . l:flags
execute 's/|\( \+\):/|:\1/e' . l:flags
execute 's/|:\?\zs[ -]\+\ze:\?|/\=repeat("-", len(submatch(0)))/' . l:flags

normal! {
call search('|')
let l:start = line('.')
normal! }
let l:end = line('.')
let l:indent_pat = '^' . l:indent . '\zs \ze|'
for l:lnum in range(l:start, l:end)
call setline(l:lnum, substitute(getline(l:lnum), l:indent_pat, '', ''))
endfor

call setpos('.', l:pos)
endfunction

Expand Down