chrisbra / csv.vim

A Filetype plugin for csv files

Home Page:http://www.vim.org/scripts/script.php?script_id=2830

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alternate column coloring does not work if user hits Space after last column, documentation does not say whether to explicitly select last column's width or leave it for csv.vim to decide

poetaman opened this issue · comments

Let's say there are 3 fixed-width columns, and one used the wizard to set column widths. The keystroke to mark a column ending is <Space>. If I hit <Space> at some point after column 1 & 2, and then press <CR>, then things work well (all 3 columns are correctly detected, I check this by looking at alternate column coloring and column highlighting). Though this doesn't explicitly set the width of 3rd column, I would guess everything is considered till the end... It took me some while to get this right... I was hitting <Space> after all 3 columns to select their "widths", this breaks it somehow: column alternate coloring doesn't work.

In the following csv, | indicates places where I hit <Space>, and $ indicates position where I hit both <Space> followed by <CR>. In this case alternate column coloring is broken.

Case-1:
         |           |           $
vvrv        dewfwe      rf          
a           frv         fe          
rvbrrr      reerbe      frvrbr      
rrr         a           affe        
dfff        qdf         aaaadff     

And this case is fine:

Case-2:
         |           $           
vvrv        dewfwe      rf          
a           frv         fe          
rvbrrr      reerbe      frvrbr      
rrr         a           affe        
dfff        qdf         aaaadff     

Screenshots:
If :let g:csv_highlight_column = 'y' is not executed before :CSVFixed
Case-1: (this is the only broken case! see column colors don't alternate)
Screen Shot 2021-02-22 at 6 56 34 AM

Case-2:
Screen Shot 2021-02-22 at 6 57 06 AM

If :let g:csv_highlight_column = 'y' is executed before :CSVFixed then there is no problem, both Case-1 and Case-2 foreground and background colors are fine:

Case-1:
Screen Shot 2021-02-22 at 6 57 45 AM

Case-2:
Screen Shot 2021-02-22 at 6 58 25 AM

NOTE
·
·
You should mention in the wizard documentation that users should hit <Space> only between columns, and not after last column, as the wizard then thinks that there is one more column at the end (which will be completely empty)
·
·
NOTE_END

Oh wow, you have created a lot of issues here lately. I will have a look and work myself through it slowly. Currently I don't have much time to spend on any hobby projects, so please be patient.

@chrisbra Yes of course :) Thanks for maintaining this!

@chrisbra I have been playing with https://github.com/andmarti1424/sc-im. It has vim bindings, among other amazing features. Given Vim now implements :terminal & given sc-im has a lua interface, it might be worth considering to support (by using, donating, collaborating on it) than maintaining this. Vimscript is slow as we are discussing it there: #178 (comment)

I know sc-im is an alternative. But for one I am not sure how well this will work on Windows (not sure if there exists binaries) and I am not interested in developing in lua.

I am already overloaded with my current Open Source work, I do not have any resources for contributing on other projects. I hope Vim9 script will improve performance and I rather like to have a complete embedded project within vim, that does not rely on external tools.