Skip to content

Commit

Permalink
add support for tables without borders
Browse files Browse the repository at this point in the history
i.e.
```
header 1|header 2
--|--
data 1|data 2
```
  • Loading branch information
gko committed Sep 22, 2023
1 parent 4e9b4de commit 32a4332
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ftplugin/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,15 @@ endfunction
"
function! s:TableFormat()
let l:pos = getpos('.')

normal! {
call search('|')
execute 'silent .,''}s/\v^(\s{0,})\|?([^\|])/\1|\2/e'

normal! {
call search('|')
execute 'silent .,''}s/\v([^\|])\|?(\s{0,})$/\1|\2/e'

normal! {
" Search instead of `normal! j` because of the table at beginning of file edge case.
call search('|')
Expand Down Expand Up @@ -765,7 +774,7 @@ endif
command! -buffer -range=% HeaderDecrease call s:HeaderDecrease(<line1>, <line2>)
command! -buffer -range=% HeaderIncrease call s:HeaderDecrease(<line1>, <line2>, 1)
command! -buffer -range=% SetexToAtx call s:SetexToAtx(<line1>, <line2>)
command! -buffer TableFormat call s:TableFormat()
command! -range TableFormat '<,'> call s:TableFormat()
command! -buffer Toc call s:Toc()
command! -buffer Toch call s:Toc('horizontal')
command! -buffer Tocv call s:Toc('vertical')
Expand Down

0 comments on commit 32a4332

Please sign in to comment.