Quantcast

Mode for tab-delimited files?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Mode for tab-delimited files?

Benjamin R. Haskell-8
Is there a filetype or way to set vim up nicely for tab-delimited files?  
What I'm looking for is to have tab characters force vertical alignment
of the following characters.  E.g., using » to indicate the tabs, I'd
like the following:

1»longer-than-a-tab»bar»long column with spaces
2222»»baz»shorter

to be displayed as (where »· are from my preference: 'set listchars=tab:»·'):

1»···longer-than-a-tab»bar»long column with spaces
2222»»·················baz»shorter

I guess it's kind of like 'dynamic tabstops' (where the content
determines the length of each 'stop').  Is there a simple way to do
this?

--
Thanks,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mode for tab-delimited files?

Christian Brabandt
Hi Benjamin!

On Do, 11 Mär 2010, Benjamin R. Haskell wrote:

> Is there a filetype or way to set vim up nicely for tab-delimited files?  
> What I'm looking for is to have tab characters force vertical alignment
> of the following characters.  E.g., using » to indicate the tabs, I'd
> like the following:

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

Then open your file and
1) :let g:csv_delim="^I"
2) :InitCSV
3) :ArrangeColumn

(^I represents the character Tabulator, and not the 2 letters ^ and I)


regards,
Christian

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mode for tab-delimited files?

Benjamin R. Haskell-8
On Thu, 11 Mar 2010, Christian Brabandt wrote:

> On Do, 11 Mär 2010, Benjamin R. Haskell wrote:
>
> > Is there a filetype or way to set vim up nicely for tab-delimited
> > files?  What I'm looking for is to have tab characters force
> > vertical alignment of the following characters.  E.g., using » to
> > indicate the tabs, I'd like the following:
>
> Try http://www.vim.org/scripts/script.php?script_id=2830
>
> Then open your file and
> 1) :let g:csv_delim="^I"
> 2) :InitCSV
> 3) :ArrangeColumn
>
> (^I represents the character Tabulator, and not the 2 letters ^ and I)

Using that sequence, I seem to lose all my tabs.

e.g., after step 3), this logical text (again, » = <Tab>):

0»1»1.00»101010
1»2»1.00»101010000101

which shows up with my default settings (listchars='tab:»·,trail:·') as:

0»··1»··1.00»···101010
1»··2»··1.00»···101010000101

becomes:

0  1  1.00  101010·······
1  2  1.00  101010000101·

...ah, and after composing that, I see why:

In ArrangeCol, there's this comment:

" If a delimiter is a <Tab>, replace it by Space
(and then it does)


Possible bug:  Even without the :ArrangeColumn, :SearchInColumn 4 /0000/  
doesn't find the 0000 in the fourth column.  (Though this works:
:SearchInColumn 3 /00/)

The plugin also seems to handle all of those horrible CSV quoting rules.  
(Which, of course, it should, for editing CSV data)  That's the main
reason I vastly prefer tab-separated.  (And the many *nix tools that
operate on tab-separated.)

Thanks anyway for pointing this out (I'm keeping it installed for true
CSV).

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mode for tab-delimited files?

Christian Brabandt
Hi Benjamin!

On Fr, 12 Mär 2010, Benjamin R. Haskell wrote:

>
> which shows up with my default settings (listchars='tab:»·,trail:·') as:
>
> 0»··1»··1.00»···101010
> 1»··2»··1.00»···101010000101
>
> becomes:
>
> 0  1  1.00  101010·······
> 1  2  1.00  101010000101·
>
> ...ah, and after composing that, I see why:
>
> In ArrangeCol, there's this comment:
>
> " If a delimiter is a <Tab>, replace it by Space
> (and then it does)

That was intended. Well, acutally I think I could keep the tabs.

> Possible bug:  Even without the :ArrangeColumn, :SearchInColumn 4 /0000/  
> doesn't find the 0000 in the fourth column.  (Though this works:
> :SearchInColumn 3 /00/)
>
> The plugin also seems to handle all of those horrible CSV quoting rules.  
> (Which, of course, it should, for editing CSV data)  That's the main
> reason I vastly prefer tab-separated.  (And the many *nix tools that
> operate on tab-separated.)
>
> Thanks anyway for pointing this out (I'm keeping it installed for true
> CSV).

Yeah, there are a couple of other nasty bugs (unfortunately the RE is
not quite right yet. It seemed to work fine, but I just got a report
about it being broken), I just found out. I'll update the plugin as soon
as possible. BTW: Please give me some sample data, so I can test the
bugfix.

regards,
Christian

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Loading...