In vim, assuming your file is open, do the following:
[list=1][*]Hit ":"[*]Enter "1000,1450 y" (substitute the line numbers you want, the first one being the first and the second on being the last)[*]Hit ":"[*]Enter "sp lines_wanted.txt" (or whatever filename you want)[*]Hit "p"[/list=1]
Repeat, substituting the last step with "$ p" to append to the file.
And that's it! You could do it in ex (what vi is built on) as well. You could also do it in vim in visual mode, by hitting "V" and selecting the lines you want. When you have them selected, just hit "y" and put (by hitting "p") it in the new file. Tip: switch windows by hitting ^w followed by a direction (j, k, h, l, or one of the arrow keys).
If you wanted to retain the line numbers, I'd recommend you run "cat -n" on your file and redirect the output to a new file, and then follow the steps above for the new file. I don't know if vim can yank line numbers as well. It just might!
Edit: I notice that you might want a fancier way of doing this, and I messed around a bit and didn't come up with a perfect solution yet.
Last edited by prell; 09-23-2004 at 01:26 PM.
|