Home / Programming / Vi / How can I save part of a file to a new file in vi?
How can I save part of a file to a new file in vi?
Last updated: 05/21/2012
Sometimes it's nice to be able to pull out a piece of code or text from a file and save it to a new file. Maybe you just need lines 48-105 of a file and want to easiyl extract that.
In vi, you can do the following while editing the file:
:48,105w smallerfile.txt
this will save the lines 48-105 to the "smallerfile.txt"