Moving Text In vi(1) To Another File
rodney.lewis at tortoiseblog.com
Fri Aug 29 12:00:17 UTC 2014
On 2014-08-29 09:20, 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?
> I have the source file open; I yank the text region then, do I open a
> new file/buffer first or is there a command to 'redirect' the data to?
There are several ways to do this but I prefer the old ex commands. It's
just the way my brain works.
First I enable visible line numbers so I know what's where.
You can then use the following to write out to a new file.
Select lines 10 to 30
Or append lines 45 to 66 to newfile
To copy text chunks around a file
Copy line 45,66 and insert at line 90
Or substitute mo to move it
You can also use d to delete chunks of text
Delete line 78 to 88
Hope this helps
More information about the freebsd-questions