Moving Text In vi(1) To Another File

Andrew Hamilton-Wright AHamiltonWright at
Fri Aug 29 13:14:57 UTC 2014

On Fri, 29 Aug 2014, Polytropon wrote:

> On Fri, 29 Aug 2014 09:20:46 +0100, Jamie Griffin wrote:
>> What is the best way to copy large sections of text in a file and copy
>> it to another file, possibly a new file or not. Is vi even the best
>> utility to do that?
> The "best" utility is the one you're most familiar with,
> regarding the particular task.

Good advice.

This is easy in vi, as 'w' (write) works essentially the same as
(command-line) yank.  Assuming you are yanking your data via
something like:
(with 100 and 200 standing in as the line range), then you can
simply do this instead
 	:100,200w myNewFile
 	:100,200w /my/new/faraway/file
if you want to include a path to the file.


More information about the freebsd-questions mailing list