Reputation: 1
I have a file that looks a bit like this
foo
! START
bar1
! END
foo
! START
bar2
! END
foo
Is there a way of yanking text that lives between the lines containing START and END patterns? I.e. to get
bar1
bar2
I know that doing
g/START/+1y
would do it for this exact example, but I'm looking for a solution that copies all lines that are bound between some pattern or a start and end pattern, regardless of how many lines exist between them.
Help! :)
Upvotes: 0
Views: 47
Reputation: 58491
You can use a global command
qqq
:g/! START/+1,/! END/-1 y Q
Explanation
qqq -> clears the q register
:g -> starts a global command
! START -> search for
+1 -> start a range at search match +1
/! END/-1 -> up until ! END -1
y Q -> append into Q register
Upvotes: 3