Hi, thank you very much to both of you.
I'm sorry I didn't post earlier but I didn't had the time to try your
tips

After experiment a little, I finally solved it by:

g/^\d\+\./exec '.w! >> '.(['Buddingtonite.txt', 'Alunite.txt',
'calcite.txt', 'kaolinite.txt'][line('.')%6])

g seems to be a very powerful command that I really need to learn.
I got a few questions for you:

John

what exactly does the + and the , ?
I understand +,+ jumps a line (so is not deleted), but for the file C
you just use +

Tim

^\d\+\.   any line that begins with one (or more) decimal numbers
followed by a dot

I don't understand everything this part
/exec '.w! >> '.(['D', '', '', 'A', 'B', 'C'][line('.')%6])

after exec, can you write any command?

.w      what is this dot for?
>>     like > in shell?
'.       again, what is this dot for?

(['D', '', '', 'A', 'B', 'C'][line('.')%6])  I think I understand it,
but where can I read about this kind of things?
([List of files][a way to send different parts to the different files
in the previous list])
line('.')   why '.' ? is there a way to chose characters, words or
paragraphs instead of lines?

To both of you

where can I read about g command?
I have tried :help g, but I get " 2.4 Commands starting with 'g' "
Again, thank you for your fast answers and sorry about my late one.
Sorry about my English too, just in case.

On 19 mar, 03:00, Tim Chase <[email protected]> wrote:
> Jorge Tim n wrote:
> > Hi, I have a file numbers in gropus of four that i want to separate
> > this way:
>
> > -
> > 0,2010
> > 0.149036564840167          ----------------> To File A
> > 0.174286165702154          ----------------> To File B
> > 0.148561021969625          ----------------> To File C
> > 0.197299757855822          ----------------> To File D
> > -
> > 0,2020
> > 0.148538114790534          ----------------> To File A
> > 0.174768764182483          ----------------> To File B
> > 0.152110261402346          ----------------> To File C
> > 0.204325268521311          ----------------> To File D
> > -
> > 0,2030
> > 0.14405206434384             ...
> > 0.172445966573654
> > 0.157687637653766
> > 0.203154350077063
> > -
> > ...
>
> > I'm just starting to learn how to use vim, but I'm sure this
> > repetitive task can be managed efficiently using vim.
>
> Though almost opaque in its terseness, my first attempt processes
> the whole file into its respective bits in one pass:
>
> :g/^/if (line('.')%6>2 || !(line('.')%6)) | exec '.w! >> '.(['D',
> '', '', 'A', 'B', 'C'][line('.')%6]) | endif
>
> or depending on the format, if the data lines are the only ones
> with periods in them (identified by the regexp "^\d\+\.") then
> that can be reduced to:
>
> g/^\d\+\./exec '.w! >> '.(['D', '', '', 'A', 'B', 'C'][line('.')%6])
>
> > But is there a way to select certain lines or something similar?
>
> I archived this email from Preben "Peppe" Guldberg (speaking of
> whom, I don't remember seeing him on the list recently and hope
> he's okay) which does something like what you describe in
> response to a similar question:
>
> P> Assuming you want to keep the first and every tenth line in
> the buffer,
> P> you could use eg.
> P>
> P>     :g/^/+d9
> P>
> P> If you want to keep every tenth line, you need a little magic:
> P>
> P>     :g/^/d9|m.
> P>
> P> Here nine lines are deleted and the tenth is moved after itself.
> P> This little trick removes the tenth line from the list of
> lines that
> P> :global processes (as does the deletion of line 2 to 9).
>
> You might be able to adapt it for your purposes.
>
> > Any suggestion to do it faster will be appreciated.
>
> However, if you don't want to process each case by hand, you can
> use my ugly stunt above that does the whole thing in one pass.
>
> -tim

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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to