[comp.editors] Deleting blocks in vi

robert@arizona.edu (Robert J. Drabek) (03/16/89)

In article <960@myrias.UUCP>, dbf@myrias.UUCP (David Ferrier) writes:
> In article <4048@ttidca.TTI.COM> kevin@ttidcb.tti.com (Kevin Carothers) writes:
> >I am continuously amazed at the lack of knowledge about Vi some of the 
> >people who post to this newsgroup display!
> >NO, you DO NOT have to count lines! [to delete a block of text] 
> >1.  Mark the beginning and end of your block of text 
> >    Lets say the beginning is register "a", and the end is "b".
> >2.  Enter the following command:
> >    :'a,'bw !wc -l
> >           +---- This space is very important.
> >If you don't like Vi, fine. Just don't post untrue junk about it.
> 
> It also highlights the problem that in vi there is no EASY, OBVIOUS way 
> to delete a large block of text.  For dozens of other editors, 
> the procedure is "Just Say Delete".

Most people use   dd   to delete a line.

But there IS a way to "Just Say Delete": it is   d   (lower-
case letter d) followed by a move command.

Note:

dfx	Delete from the cursor to where the letter x is found on the
	current line.  Of course, x can be any character.

dG	Delete everything to the end of the file

d100G	Delete everything to line 100.

d/pat	Delete to where the pattern   pat   is found.

dh	Delete the previous character.

d0      Delete everything on the line up to the cursor.

d4w	Delete four words.

d}      Delete to the end of the paragraph.

I guess you've gotten the idea from these examples.

To delete a marked block as in Kevin's example is much, much easier
than as given.  Mark the last part of the block to be deleted by going
there and typing   ma   (this marks the spot with a label a).  Move
to the beginning of the block and type

d'a


> When vi also becomes user-friendly, 
> clearly documented, and easy to use, please post.

Agreed, vi is not clearly documented.  Few things are, but I have
noticed an improvement in documentation of some new software over the
years.  Or maybe I am just getting better at reading it.
-- 
Robert J. Drabek
Department of Computer Science
The University of Arizona
Tucson, AZ  85721