Skip to content

Commit

Permalink
CSVTable: Allow to request ascii drawing chars
Browse files Browse the repository at this point in the history
closes: chrisbra#184
Signed-off-by: Christian Brabandt <[email protected]>
  • Loading branch information
chrisbra committed Dec 1, 2023
1 parent 56d1aa5 commit 9331e5b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -939,9 +939,12 @@ In csv files, you can also use the :CSVTabularize command, in different
filetypes you can use the :CSVTable command (and is available as plugin so it
will be available for non-CSV filetypes).

Set the variable g:csv_table_leftalign=1 if you want the columns to be
Set the variable `g:csv_table_leftalign=1` if you want the columns to be
leftaligned.

Set the variable `g:csv_table_use_ascii=1` if you do not want to use unicode
drawing characters.

Note: Each row must contain exactly as many fields as columns.

This command is available as default plugin. To disable this feature, set the
Expand Down
28 changes: 14 additions & 14 deletions autoload/csv.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2650,21 +2650,21 @@ fu! csv#Tabularize(bang, first, last) "{{{3
endif
let _c = winsaveview()
" Table delimiter definition "{{{4
if !exists("s:td")
let s:td = {
\ 'hbar': (&enc =~# 'utf-8' ? '' : '-'),
\ 'vbar': (&enc =~# 'utf-8' ? '' : '|'),
\ 'scol': (&enc =~# 'utf-8' ? '' : '|'),
\ 'ecol': (&enc =~# 'utf-8' ? '' : '|'),
\ 'ltop': (&enc =~# 'utf-8' ? '' : '+'),
\ 'rtop': (&enc =~# 'utf-8' ? '' : '+'),
\ 'lbot': (&enc =~# 'utf-8' ? '' : '+'),
\ 'rbot': (&enc =~# 'utf-8' ? '' : '+'),
\ 'cros': (&enc =~# 'utf-8' ? '' : '+'),
\ 'dhor': (&enc =~# 'utf-8' ? '' : '-'),
\ 'uhor': (&enc =~# 'utf-8' ? '' : '-')
let use_unicode = &enc =~# 'utf-8' && get(g:, 'csv_table_use_ascii', 0) == 0
let s:td = {
\ 'hbar': (use_unicode ? '' : '-'),
\ 'vbar': (use_unicode ? '' : '|'),
\ 'scol': (use_unicode ? '' : '|'),
\ 'ecol': (use_unicode ? '' : '|'),
\ 'ltop': (use_unicode ? '' : '+'),
\ 'rtop': (use_unicode ? '' : '+'),
\ 'lbot': (use_unicode ? '' : '+'),
\ 'rbot': (use_unicode ? '' : '+'),
\ 'cros': (use_unicode ? '' : '+'),
\ 'dhor': (use_unicode ? '' : '-'),
\ 'uhor': (use_unicode ? '' : '-')
\ }
endif "}}}4
"}}}4
if match(getline(a:first), '^'.s:td.ltop) > -1
" Already tabularized, done
call csv#Warn("Looks already Tabularized, aborting!")
Expand Down
5 changes: 4 additions & 1 deletion doc/ft-csv.txt
Original file line number Diff line number Diff line change
Expand Up @@ -911,9 +911,12 @@ In csv files, you can also use the :CSVTabularize command, in different
filetypes you can use the :CSVTable command (and is available as plugin so it
will be available for non-CSV filetypes).

Set the variable g:csv_table_leftalign=1 if you want the columns to be
Set the variable `g:csv_table_leftalign=1` if you want the columns to be
leftaligned.

Set the variable `g:csv_table_use_ascii=1` if you do not want to use unicode
drawing characters.

Note: Each row must contain exactly as many fields as columns.

This command is available as default plugin. To disable this feature, set the
Expand Down

0 comments on commit 9331e5b

Please sign in to comment.