From owner-freebsd-questions@FreeBSD.ORG Fri Aug 29 08:47:31 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 06EF2370 for ; Fri, 29 Aug 2014 08:47:31 +0000 (UTC) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BEB721A56 for ; Fri, 29 Aug 2014 08:47:30 +0000 (UTC) Received: from r56.edvax.de (port-92-195-111-1.dynamic.qsc.de [92.195.111.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id 887D93CC79; Fri, 29 Aug 2014 10:47:26 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id s7T8lQgx002986; Fri, 29 Aug 2014 10:47:26 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Fri, 29 Aug 2014 10:47:26 +0200 From: Polytropon To: Jamie Griffin Subject: Re: Moving Text In vi(1) To Another File Message-Id: <20140829104726.dc4aa238.freebsd@edvax.de> In-Reply-To: <540037DE.4030404@gmail.com> References: <540037DE.4030404@gmail.com> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: FreeBSD Questions X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2014 08:47:31 -0000 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. When I read your task, I immediately thought: "Well, that sounds like a job for joe." (joe = Joe's own editor, a WS-inspired advanced text editor). I'd work like that: % joe input.txt move cursor to text segment you want to copy cursor and page scroll keys work as expected ^KB (block begin) -> where to begin ^KK (block end) -> where to stop begin and end can be set independently (!) without losing the selection ^KE out1.txt creates new file or opens existing file if existing file: move cursor to where you want the segment to be copied at ^KC (block copy) ^KX (save and exit) file out1.txt will be closed, you're back at input.txt repeat from ^KB/^KK step as needed ^C Y (exit without saving - refers to input.txt file) when done Note that you can use ^KN (next) and ^KP (prev) to switch between the files you're editing. If you want to move a block of text rather than copying it, use ^KM instead of ^KC; this changes the input file. At the end of the session, use ^KX to save it, or ^C Y to lose the changes. You can surely solve the task with vi, but my use of vi is too limited in order to give you the required advice, that's why I suggested a different editor. It's not that vi cannot do it. It's just that I can't remember how, at the moment. Still I hope this comment will be helpful for you. :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...