tags:

views:

36

answers:

1
:/From book:/,/$/ cmd_copy chapters_from_match_@From_book@_until_end_of_line.txt

I tried not to use words "write", "put" or "read" as VIM has special meaning for them. I try to copy (sorry not referring to VIM's copy-command) the thing between matches to a file. How do you do it, without copying the whole lines?

Dummy example

TEXT:

do not copy me dummy1 hello world please copy me dummy2 do not copy me

some enters, should work also with enters btw the matchpoints dummy1 not yet!

not yet!

copy will end soon! dummy2

COPIED:

hello world please copy me

or

dummy1 hello world please copy me dummy2

A: 

so, why not use

:1s/^\_.\{-}dummy1//    "first line: delete everything until first occurrence of dummy1
:%s/dummy2\zs\_.\{-}\zedummy1/\n/
:1s/\_.*dummy2\zs\_.*// "delete from last occurrence of dummy2 till EOF
Benoit