Date: Fri, 29 Aug 2014 07:25:35 -0500 From: "William A. Mahaffey III" <wam@hiwaay.net> Cc: FreeBSD Questions <freebsd-questions@freebsd.org>, owner-freebsd-questions@freebsd.org Subject: Re: Moving Text In vi(1) To Another File Message-ID: <5400713F.7080500@hiwaay.net> In-Reply-To: <782f4b6466266500ebcc15173fef385b@tortoiseblog.com> References: <540037DE.4030404@gmail.com> <782f4b6466266500ebcc15173fef385b@tortoiseblog.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 08/29/14 06:51, Rodney Lewis wrote: > 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. > > :set nu > > You can then use the following to write out to a new file. > Select lines 10 to 30 > :10,30w ~/newfile > > Or append lines 45 to 66 to newfile > > :45,66w >>~/newfile > > > To copy text chunks around a file > Copy line 45,66 and insert at line 90 > > :45,66co90 > > Or substitute mo to move it > > :45,66mo90 > > You can also use d to delete chunks of text > Delete line 78 to 88 > :78,88d > > Hope this helps > > Rodney > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" > .... & of course, ex commands are available from within 'vi' using the same syntax as above .... -- William A. Mahaffey III ---------------------------------------------------------------------- "The M1 Garand is without doubt the finest implement of war ever devised by man." -- Gen. George S. Patton Jr.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5400713F.7080500>