Hi Hattori!

On Sa, 12 Dez 2009, Hattori Hanzo wrote:

> Mostly, sequences are received from online databases. The files contain
> "returns", which make it hard to easily process the files. I found out, that
> with the vim command :x,yj! I can join all lines from x to y without spaces.
> As i want the fasta file to consist of only two lines (header and sequence)
> I wonder if it's possible to tell vim to join all lines from line 2 to the
> last line of the file without having to look up the line number of the file.
> I imagine somting like :2,"last line of the file"j!. Is that possible?

You can use :2,$j!

(Usually $ stands for the last line in the file).

How large are those files? If you need to join files larger say 10000 
lines, vim seriously gets hit by a performance bug. So you might be 
interested in the following plugin, which tries to mimic :j as closely 
as possible, but without being affected by that bug:
http://www.vim.org/scripts/script.php?script_id=2766

> 
> Second thing: Now i have a file consisting of the header in the first line
> and sequence in the second line. For further processing i would like to
> again introduce "returns" after a defined number of characters, e.g. 49, 69.
> I tried to find a solution in the web but didn't succeed. So i hope that you
> can help me with that problem.

You can use a substitute command. For example to enter "return" after 
every 40 char, you could issue the following command:
:%s/.\{40\}/&return;/g

which means

:%s         " form line 1 to the last execute this substitute command
/           " Search for
.\{40\}     " a sequence of 40 characters
/           " and replace
&           " the sequence by itself
return;     " and append return;
/g          " and redo this substitute for every match in each line


regards,
Christian
-- 
hundred-and-one symptoms of being an internet addict:
6. You refuse to go to a vacation spot with no electricity and no phone lines.

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

Reply via email to