While editing, you will sometimes want to save just part of your file as a separate, new file. For example, you might have entered formatting codes and text that you want to use as a header for several files.
You can combine
ex
line addressing (
33.3
)
with the write command,
w
, to save part of a file. For example, if you are in the file
practice
and want to save part of practice as the file
newfile
, you could enter:
:230,$w
newfile
Saves from line 230 to end-of-file in newfile .
:.,600w
newfile
Saves from the current line to line 600 in newfile .
[After
newfile
has been created, you'll need
w!
instead of
w
.
-JP
]
- from O'Reilly & Associates' Learning the vi Editor , Chapter 5