Reputation: 13728
How can I copy lines that is matches a pattern to another line, within a selected part of the document. I can do it for whole document with :g/\s*$data/co24
but I couldn't figure out how to apply this function to only a selected part of a document.
Upvotes: 1
Views: 102
Reputation: 311288
You can apply a range to the g
operator. For example, you can use V
to select a section of your document, then type :
, which will get you:
:'<,'>
Then you can add your g
command:
:'<,'>g/\s*$data/co24
You can also apply the range numerically, like this:
:100,150 g/\s*$data/co24
(This would apply the g
operation to lines 100-150). You can also apply a range using the search operator, like this:
:/start/,/stop/ g/\s*$data/co24
This would apply the g
operation to lines between a match for start
and a match for stop
.
Upvotes: 5
Reputation: 434
Give this a shot, as '<,'> means "within the visual selection"
:'<,'>/\s*$data/co24
Upvotes: 1