Permalink
Browse files

Allow for easier align rules

Now you can use the glob char '*' when defining how to align columns.
Use `:let b:csv_arange_align='l*'` to have all columns left aligned.

closes #99
  • Loading branch information...
1 parent 2cc7cd2 commit cceabea3adcd077003be52c4813e3b97ab13d54e @chrisbra committed Nov 30, 2016
Showing with 26 additions and 3 deletions.
  1. +2 −0 CHANGELOG.md
  2. +9 −1 README.md
  3. +9 −1 doc/ft-csv.txt
  4. +6 −1 ftplugin/csv.vim
View
@@ -85,6 +85,8 @@
https://github.com/chrisbra/csv.vim/issues/84, thanks!)
- Do not remove tabs on `:UnArrangeColumn` (reported by taylor-peterson in
https://github.com/chrisbra/csv.vim/issues/98, thanks!)
+- Allow for better aligning of columns (reported by taylor-peterson in
+ https://github.com/chrisbra/csv.vim/issues/99, thanks!)
## 0.31 Jan 15, 2015
- supports for Vim 7.3 dropped
View
@@ -232,11 +232,12 @@ overriden by setting the "b:csv_arrange_use_all_rows" variable (see below).
If [range] is not given, it defaults to the current line.
-By default, the columns will be righ-aligned. If you want a different
+By default, the columns will be right-aligned. If you want a different
alignment you need to specify this through the b:csv_arrange_align variable.
This is a string of flags ('r': right align, 'l': left align, 'c': center
alignment, '.': decimal alignment) where each flag defines the alignment for
a particular column (starting from left). Missing columns will be right aligned.
+You can use '\*' to repeat the previous value until the end.
So this:
```vim
@@ -246,6 +247,13 @@ Will left-align the first column, center align the second column, decimal
align the third column and all following columns right align. (Note: decimal
aligning might slow down Vim and additionally, if the value is no decimal
number it will be right aligned).
+And this:
+
+```vim
+:let b:csv_arrange_align = 'l*'
+```
+will left align all columns.
+
If you change the alignment parameter, you need to use the "!" attribute, the
next time you run the `:ArrangeCol` command, otherwise for performance
reasons, it won't be considered.
View
@@ -231,11 +231,13 @@ overriden by setting the "b:csv_arrange_use_all_rows" variable (see below).
If [range] is not given, it defaults to the current line.
-By default, the columns will be righ-aligned. If you want a different
+ *csv_arrange_align*
+By default, the columns will be right-aligned. If you want a different
alignment you need to specify this through the b:csv_arrange_align variable.
This is a string of flags ('r': right align, 'l': left align, 'c': center
alignment, '.': decimal alignment) where each flag defines the alignment for
a particular column (starting from left). Missing columns will be right aligned.
+You can use '*' to repeat the previous value until the end.
So this: >
:let b:csv_arrange_align = 'lc.'
@@ -244,6 +246,12 @@ Will left-align the first column, center align the second column, decimal
align the third column and all following columns right align. (Note: decimal
aligning might slow down Vim and additionally, if the value is no decimal
number it will be right aligned).
+And this: >
+
+ :let b:csv_arrange_align = 'l*'
+
+Will left align all columns.
+
If you change the alignment parameter, you need to use the "!" attribute, the
next time you run the |:ArrangeCol| command, otherwise for performance
reasons, it won't be considered.
View
@@ -761,7 +761,12 @@ fu! <sid>Columnize(field) "{{{3
let width = get(b:col_width, colnr, 20)
let align = 'r'
if exists('b:csv_arrange_align')
- let align_list=split(get(b:, 'csv_arrange_align', " "), '\zs')
+ let align=b:csv_arrange_align
+ let indx=match(align, '\*')
+ if indx > 0
+ let align = align[0:(indx-1)]. repeat(align[indx-1], len(b:col_width)-indx)
+ endif
+ let align_list=split(align, '\zs')
try
let align = align_list[colnr]
catch

0 comments on commit cceabea

Please sign in to comment.