[Coco] VI Editor

John W. Linville linville at tuxdriver.com
Tue Feb 20 14:26:46 EST 2018


On Mon, Feb 19, 2018 at 06:00:24PM -0500, phil pt wrote:
> Does anyone know the VI commands to move the cursor to the start mark a
> block then move the cursor down and mark the end block and copy & past it
> in the file.  checked the internet and I can not find any clear steps on
> how to do it?

<Move to the top line of the block you want to copy...>
mx
<Move to the bottom line of the block...>
y'x
<Move to the place you want to paste it...>
p

<Or, move to the top line of the block you want to delete...>
mx
<Move to the bottom line of the block and delete it...>
d'x
<Move to the place you want to paste it...>
p

The "x"s above can be any letter (possibly any character) so long as
the "mark" (m) and the "yank" (y) match. In my head, I say "mark x,
yank from x, paste" or "mark x, delete from x, paste".

The above works for one buffer at a time. One can also use named
buffers, like this:

<Move to the top line of the 1st block you want to copy...>
mx
<Move to the bottom line of the 1st block...>
"ay'x
<Move to the top line of the 2nd block you want to delete...>
mx
<Move to the bottom line of the 2nd block...>
"bd'x
<Move to the place you want to paste the 1st block...>
"ap
<Move to the place you want to paste the 2nd block...>
"bp

The buffer identifiers are a " character followed by a single
character. Characters used for buffer identifiers can be reused for
block markers and vice versa -- the " characters separates the usage
of a character between blocks and buffers.

The ability to handle cut and paste of blocks without ever moving your
hands from the keyboard has made vi and its clones/successors a joy to
use for me over the years -- far superior to anything with a mouse and
incalculably better than that other editor that talks with a LISP...

The above should work even on relatively old versions of vi, even from
well before vim existed. If it doesn't work, contact the author of
whatever vi fraud you are suffering to use... ;-)

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville at tuxdriver.com			might be all we have.  Be ready.


More information about the Coco mailing list