Friday, January 29, 2010

Re: Adjusting line lengths

On 13/12/09 12:59, Hattori Hanzo wrote:
>
> Hello,
>
> and thanks to all of you!
>
> The joining issue is solved by
>
> :2,$j!
>
> and the splitting issue by
>
> :s/.\{49}/&\r/g
>
> As I'm working with genes, files are not that big and contain about 10000
> characters. However, when it comes to genomes, sequence lengths will get
> bigger. Therefore also thanks for the tip with file sizes beyond 10000
> lines.
>
> David

Also, you may prefer to only join lines not starting with >. I think the
following (untested) will do it:

:%s/^[^>].*\zs\n\ze[^>]//

Explanation: replace a line-break by nothing if preceded by
(start-of-line then not a > then zero or more of anything) and followed
by (not a > character). It _will_ join any number of lines, possibly
creating very long lines, with the performance hit that goes with it.

See
:help pattern-overview

which (until the next line of ====) is a kind of "cheat sheet" about
search patterns.

One Vim quirk which is relevant here (and also for your other question,
of breaking the long line into shorter lines of fixed length) is that
you *match* a line break with \n but (in the second part of an :s
command) you *insert* a line break with \r

Best regards,
Tony.
--
The typewriting machine, when played with expression, is no more
annoying than the piano when played by a sister or near relation.
-- Oscar Wilde

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment