vi: write relative range of lines to a file

vi: write relative range of lines to a file

I need to be able to write a range of lines from a file to another file, I’ve found the :<start>,<end>w <new file> solution but what I need is to be able to search for a string and write a a few lines to another file starting at the “found” location. Using .,. works to get one line but what if I want, say, 10 lines? Adding to the complexity is that I want to do this in a script. How do I do that (can I turn on Visual Mode in a script and then move the cursor)?

Go to Source
Author: Senior Geek