Vim Tips Wiki
Register
Advertisement

Use this page to discuss script 2830 csv: filetype plugin for csv files

  • Add constructive comments, bug reports, or discuss improvements (see the guideline).
  • Do not document the script here (the author should do that on vim.org).
  • This page may be out of date: check the script's vim.org page above, and its release notes.

Uninstall?[]

How do I uninstall this plugin?

Open the csv*.vmb file with your vim and type :RmVimball %. That should uninstall the plugin. See also the help :h :RmVimball. Chrisbra 21:49, March 13, 2012 (UTC)

Sort request[]

When sorting it would be nice to avoid sorting the header row(s).

:2,nSort! 3

I tried the above but it not seem to work as expected. Doh! Just realised that the following was what I need to use:

:2,$Sort! 3

Excuse the Vim newbie!

No problem. If you have questions, it might be better to ask me directly, cause I might not notice if something changes here Chrisbra 09:17, September 16, 2011 (UTC)

Bug report[]

I see a bug. With the following csv file:

1,2,3
45,67,890

If the cursor is on the "3", command ":WhatColumn" gives 0. I'd expect it to give 3.

It would also be nice to have a setting where highlighting follows the current column when moving the cursor with something like this:

au CursorMoved * HiColumn

--Preceding unsigned comment added by Dominiko 19:32, July 25, 2010

No idea about the plugin, but you do know that CSV works well? In the CSV tip, we decided against having the column highlighting change when you simply moved the cursor elsewhere because it's handy to keep track of what column you were last "interested" in (I think). Anyway, if you haven't tried it, give it a go and let me know what you think. JohnBeckett 10:38, July 26, 2010 (UTC)
Thanks, for pointing it out. I must admit, the script's RE does probably not always work best. But I see, how I can fix it. Chrisbra 17:25, July 28, 2010 (UTC)
Please try the version from github. That should have fixed it. Chrisbra 10:04, February 16, 2011 (UTC)

Comments[]

Hello, i really like your CSV script. One possible improvment could be a 'Column Header'. Like the command 'Header' freezes the first line, such a command could freeze the first column.

Some CSV is like:

  • item,1,2,3
  • stuff1,12,35,46
  • stuff2,12,35,46
  • stuff3,12,35,46
  • stuff4,12,35,46

jjinkou

This is harder than it sounds. First you could only have one Header, either horizontally or vertically. So you can't use both at the same time. Second the column can be different wide. So one needs to define the optimal width.
Let me see, what I can do. Chrisbra 22:26, February 23, 2011 (UTC)
Please try version 0.11. That adds an :VHeader command.
regards, Chrisbra 20:40, February 24, 2011 (UTC)

Bug report[]

The column colo(u)rs are corrupt.

To get black and grey backgrounds to the columns, one must write:

" here ctermbg is the BACKGROUND colour for the EVEN columns
" here ctermbg is the FOREGROUND colour for the ODD  columns
autocmd Filetype csv hi CSVColumnEven   ctermfg=white       ctermbg=darkgray
autocmd Filetype csv hi CSVColumnOdd    ctermfg=black       ctermbg=white

in their vimrc file

I can't see why the colors are corrupt. The default color for CSVColumnEven is already defined like this. If you want to change the default color for CSVColumnOdd, put this in your .vimrc :hi CSVColumnOdd ctermfg=black ctermbg=white. This is also explained in the help below :h csv-syntax Chrisbra 11:10, April 4, 2012 (UTC)

Bug report[]

E315: ml_get: invalid line number

Going to the last line causes the above error. CSV specific highlighting disappears. Other functionality is unaffected. Videokunst Sun Jul 29 15:07:23 CEST 2012

I don't see that error, but it looks like a Vim bug. What Version of Vim are you using? Have you set any of the csv specific options? I possibly need a sample file, with which you see the error.
If so, which ones? You might want to file a bug at the github page, so I can better track down this error. Chrisbra (talk) 11:58, August 5, 2012 (UTC)
In fact it is a confirmed Vim bug. I'm using Vim 7.3. Videokunst Sun Aug 5 22:43:47 CEST 2012

Replace text in highlighted column[]

Maybe a new functionality request, if it can be done now please let me know. I'm trying to replace value A in particular column by value B. Normally I would use vertical visual select and :'<,'>s/\%VA/B/g . If the csv plugin is able to highlight particular column, it may be able to replace A->B in highlighted fields. --Tpolak (talk) 10:02, July 24, 2012 (UTC)

You should be able to use :SearchInColumn /pat/ and then you can use :%s//Value B/ That should already do. You might need to do the :s/ call several times, if the value A happens to be in that particular column several times. By the way, you might want to email feature requests directly to me or use the bugtracker at github.com, because I don't watch this page regularly. Chrisbra (talk) 14:05, July 26, 2012 (UTC)

Highlight row[]

The :HiColumn is useful, and it seems like there also should be a way to highlight a given row. Is there a way to do it already that I simply lack the vim-fu to intuit?

How about using cursorline? Try :set cursorline Is this what you want? Chrisbra (talk) 12:32, October 27, 2012 (UTC)

SumColumn in Expressions[]

I'm trying to sum columns 2 and 3, up to the current line, with (Insert Mode) <C-R>=call('SumCol',[getline(2,line('.'))])+call('SumCol',[getline(3,line('.'))]). I get "E117: Unknown function: SumCol". Is there a way to use SumCol inside an expression? --Monking (talk) 04:29, March 13, 2014 (UTC)

Sorry for answering late. Although I follow this site, I did not get any notifications of your comments ;(. If you want to sum column 2 and 3 this should do it: <c-r>=csv#EvalColumn(, "<sid>SumColumn",2,3)
If you have further questions, feel free to open an issue at the plugins github repo. Chrisbra (talk) 15:02, September 9, 2014 (UTC)

Column alignment[]

When I open open a CSV file the columns delimiters are not aligned horizontally.

It looks like this:

123|1234|12345
12345|1234|12345
12|1234|12345

What I was expecting is:

123  |1234|12345
12345|1234|12345
12   |1234|12345

I don't believe the fixed width column feature applies since it is for delimiter-less files and my files have delimiters.

I've read through the docs and watched the gif, still have no idea how to clean up the display. --December 31, 2014

I have not used the plugin but it looks like it does not know that | is the delimiter. I assume the documentation shows how to specify the delimiter character to use. JohnBeckett (talk) 02:49, January 1, 2015 (UTC)
Thanks for quick response John. The delimiter in the CSV is <TAB>, not |. The plugin can be configured to use different delimiter characters as you surmise. However, I believe that regardless of which character is the actual delimiter, the plugin displays | as a visual artifact.
That is correct. The plugin does not change the actual data. If you want that, use the :ArrangeColumn command. If you do not like the syntax highlighting turn it off. You can also disable the concealing of the delimiters. That should all be documented in the help. If you have further questions, you might want to open an issue at the plugins github page. I do not follow this page here regularlyChrisbra (talk) 09:55, January 5, 2015 (UTC)
Advertisement