Wednesday, September 29, 2010

Re: Arbitrary ends of lines?

On Wed, 29 Sep 2010, Tim Chase wrote:

> On 09/29/10 13:07, Benjamin R. Haskell wrote:
>> I'm dealing with some file formats that have data segments terminated
>> by an arbitrary segment terminator (in this case '#'). Is there
>> built-in functionality for dealing with situations like this?
>>
>> It'd be nice to be able to treat this like a 'ff'.
>> ff=unix =<NL>
>> ff=dos =<CR><NL>
>> ff=mac =<CR>
>> ff={anything-else} = custom line terminator
>>
>> Since that currently doesn't exist, though, is there a plugin to do
>> roughly what that would accomplish?
>
> I don't know of a plugin, but shooting from the hip, I'd be tempted to
> use "tr" as a filter like xxd[1] is used for binary files:
>
> tr '#\012' '\012#'
>
> will swap newlines and "#" signs, which can then be reversed upon
> writing to get the originals back.

Good call. I'll likely set up something similar to the 'hex mode'[1]
tip, replacing `%!xxd` and `%!xxd -r` with perl equivs of your `tr`
example. (I want to be able to handle multi-character newlines, and I
know Perl better than sed/awk.)

I'll wikify it if I get it working nicely.

--
Thanks,
Ben

[1] http://vim.wikia.com/wiki/Improved_hex_editing

--
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

No comments:

Post a Comment