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)?
Asked
Active
Viewed 111 times
0

Senior Geek
- 55
- 9
-
Have you thought about using `sed` for this? – kenlukas May 15 '20 at 18:13
-
Thanks for the suggestion, unfortunately the nature of the situation dictates vi. – Senior Geek May 15 '20 at 20:16
1 Answers
0
A little more research searching for vi address range
surfaced the answer:
Although .,.+10
is supposed to work it didn't but the alternate form .,.10
did (from https://vim.fandom.com/wiki/Ranges to give credit where credit is due).

Senior Geek
- 55
- 9