[comp.editors] vi bashing

dbf@myrias.UUCP (David Ferrier) (03/16/89)

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.

Thanks for posting an ingenious and elegant solution. 
With my amazing lack of knowledge of vi, it would have taken me 
hours of pulling together information scattered among many 
pages of UNIX documentation on vi, ex, and wc to come up with 
this nifty get-around. 

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".  When vi also becomes user-friendly, 
clearly documented, and easy to use, please post.
-- 
David Ferrier                            | computer: 
Edmonton, Alberta                        | a million morons
UUCC:alberta!myrias!dbf                  | working at the speed of light

mercer@ncrcce.StPaul.NCR.COM (Dan Mercer) (03/17/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.
:
:Thanks for posting an ingenious and elegant solution. 
:With my amazing lack of knowledge of vi, it would have taken me 
:hours of pulling together information scattered among many 
:pages of UNIX documentation on vi, ex, and wc to come up with 
:this nifty get-around. 
:
: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".  When vi also becomes user-friendly, 
:clearly documented, and easy to use, please post.
:-- 
:David Ferrier                            | computer: 
:Edmonton, Alberta                        | a million morons
:UUCC:alberta!myrias!dbf                  | working at the speed of light

Well,  I let this go as long as I could,  but mo one else has spoken
up to correct this entry,  so I guess I have to.

Far from being ingenious and elegant,  the solution offered goes the
long way around.  Want to delete text?  Fine,  there's any number of
solutions.  Counting lines and saying,  for instance, 8dd is one,  but
very inelegant.

Want to delete the next paragraph:

                  d} 

previous paragraph:

                  d{

In vi,  the syntax is command-target for d(elete) y(ank) c(hange)
and !(shell)

Targets include:

                 (command-letter) - same line (dd yy cc !!)
                 l                  char to the right
                 j                  current line
                 k                  current an previous line
                 h                  previous char
                 H                  current line to top of screen
                 5H                 current line through 5th line from top
                 L                  current line through last line on screen
                 5L                 current line through 5th line from bottom
                 G                  current line to end of file
                 1G                 current line through 1st line of file
                 20G                current line through 20th line of file
                                    (use :set nu to set line numbering on, or
                                    control G to determine line number.     
                                    :se nonu turns off line numbering)
                 )                  current character to end of sentence
                 (                  current character to end of previous
                                    sentence
                 }                  current line through next paragraph
                 {                  current line through previous paragraph
                 ]]                 current line through next section
                 [[                 current line through previous section
                 'a                 current line through line marked by a
                 `a                 current character through character
                                    marked by a (marking previously explained)
                 /pattern           current line through line containing
                                    pattern
                 ?pattern           same, only reverse search
                 n                  through next occurrance of pattern
                 N                  through previous occurrance of pattern
                 '                  current line to previous mark
                 `                  current character to previous mark
same line        f - char           current character to found char
commands         F - char           current character to previous found char
                 ;                  current char to next found char
                 ,                  current char to previous found char
                 w                  current word (and trailing space)
                 e                  end of current word (preserve space)
                 b                  to beginning of current word

There are probably some other targets I've forgotten,  or some other
block moves that are possible.  I know of no word processing or text
editor program with so many easy ways to move and copy data.  As for
the documentation,  you need to get a UNIX editor manual (how else
can you use sed?) and play with the editor.  Man files just won't
tell you what you want to know.


-- 

Dan Mercer
Reply-To: mercer@ncrcce.StPaul.NCR.COM (Dan Mercer)

patkar@cb.ecn.purdue.edu (The Silent Killer) (03/17/89)

In article <1173@ncrcce.StPaul.NCR.COM> mercer@ncrcce.StPaul.NCR.COM (Dan Mercer) writes:
>In article <960@myrias.UUCP> dbf@myrias.UUCP (David Ferrier) writes:
>:In article <4048@ttidca.TTI.COM> kevin@ttidcb.tti.com (Kevin Carothers) writes:
>    [Stuff deleted]
>same line        f - char           current character to found char
>commands         F - char           current character to previous found char
>                 ;                  current char to next found char
>                 ,                  current char to previous found char
>                 w                  current word (and trailing space)
>                 e                  end of current word (preserve space)
>                 b                  to beginning of current word
>
>There are probably some other targets I've forgotten,  or some other


   The one I like is d% or c%, while programming.

>Dan Mercer
>Reply-To: mercer@ncrcce.StPaul.NCR.COM (Dan Mercer)

 Anant Patkar
 (patkar@ecn.purdue.edu
  seimo!pur-ee!patkar)

gast@lanai.cs.ucla.edu (David Gast) (03/19/89)

In article <960@myrias.UUCP> dbf@myrias.UUCP (David Ferrier) writes:
>Thanks for posting an ingenious and elegant solution. 

Another article already posted a better solution so I won't repeat 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".  When vi also becomes user-friendly, 
>clearly documented, and easy to use, please post.


There are objects w (for word), G (for last line of file), 'a (for
place marked a), G (for last line of file), ) (for sentence), } (for
paragraph), etc.  These objects can take counts too.

If you want to delete the next 3 paragraphs, you type d3}.  What could
be easier?  If you want to delete to the end of file, you type dG.  Not
very difficult at all and clearly documented.

David Gast
gast@cs.ucla.edu
{uunet,ucbvax,rutgers}!{ucla-cs,cs.ucla.edu}!gast

stacey@hcr.UUCP (Stacey Campbell) (03/23/89)

You gotta see this to believe it, truly a case of the moronic
leading the blind.

In article <960@myrias.UUCP> dbf@myrias.UUCP 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!

Ditto.

>>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.
             +---- This command is totally twisted.

>>If you don't like Vi, fine. Just don't post untrue junk about it.
>
>Thanks for posting an ingenious and elegant solution. 
>With my amazing lack of knowledge of vi, it would have taken me 
>hours of pulling together information scattered among many 
>pages of UNIX documentation on vi, ex, and wc to come up with 
>this nifty get-around. [...]

This little exchange just totally freaks me out.  Of all the ways
to delete text in vi I have never seen this solution, can anyone
think of a more bizarre way to do this?

For reality try...

    :'a,'bd

or if the cursor is at the end of the range for deletion...

    :'a,.d

for orthogonal functionality...

    d[any mark]

where [any mark] is:

     'a			- to mark 'a
     $			- to end of line
     /[search string]   - to char before start of [search string]
     G			- to end of file
     etc...
-- 
Stacey Campbell, HCR Corporation, {lsuc,utzoo,utcsri}!hcr!stacey

kevin@ttidca.TTI.COM (Kevin Carothers) (03/25/89)

In article 601 <24@hcr.UUCP>
From: stacey@hcr.UUCP (Stacey Campbell)

>You gotta see this to believe it, truly a case of the moronic
>leading the blind.

Wipe the spit off your chin and don't be so rude. This is a 
world-distribution discussion. You are flaming me for something which is
*YOUR* misconception.

>>'a,'bw! wc -l

>This little exchange just totally freaks me out.  Of all the ways
>to delete text in vi I have never seen this solution, can anyone
>think of a more bizarre way to do this?
>
Freak not, and listen my friend. Look at the above command. 
Do you see *ANYTHING* that looks like a "delete". NO! We're talking about 
counting lines between marks. T H A T    I S    A L L; Now go crawl back 
to wherever you came.

I, like any troll in any UNIX shop  around the universe can delete lines
ten different ways. There are many reasons why one needs to count lines 
between marks for other than deleting [ie; the ">>", "<<", "!}", etc.]. 
What I presented was the *ONLY* way I know of to "C O U N T    L I N E S 
without having to count. How many times do I have to repeat myself!

>For reality try...

For the benefit of *your* reality I'd suggest following the discussion 
more closely.

You know, I've about had enough of this.
=================================================================
Kevin Carothers   !{csun,psivax,rdlvax}!ttidca!kevin

gast@lanai.cs.ucla.edu (David Gast) (03/25/89)

In article <24@hcr.UUCP> stacey@hcrvax.UUCP (Stacey Campbell) writes:
>You gotta see this to believe it, truly a case of the moronic
>leading the blind.

>This little exchange just totally freaks me out.  Of all the ways
>to delete text in vi I have never seen this solution, can anyone
>think of a more bizarre way to do this?

>For reality try...

>    :'a,'bd
>
>or if the cursor is at the end of the range for deletion...
>
>    :'a,.d

If the cursor is at the end of the range for deletion and you want to
delete whole lines (that is what the above command does), you can just
type d'a   (only 3 strokes).

If the cursor is at the end of the range for deletion and you want to
delete on the characters between the mark and the current cursor position,
then you should type d`a

As has been pointed out, there are other objects as well.


David Gast
gast@cs.ucla.edu
{uunet,ucbvax,rutgers}!{ucla-cs,cs.ucla.edu}!gast

karish@forel.stanford.edu (Chuck Karish) (03/26/89)

In article <4129@ttidca.TTI.COM> kevin@ttidcb.tti.com (Kevin Carothers) wrote:
>In article 601 <24@hcr.UUCP>
>From: stacey@hcr.UUCP (Stacey Campbell)

 >>>'a,'bw! wc -l
 
 >>This little exchange just totally freaks me out.  Of all the ways
 >>to delete text in vi I have never seen this solution, can anyone
 >>think of a more bizarre way to do this?
 
 >Freak not, and listen my friend. Look at the above command. 
 >Do you see *ANYTHING* that looks like a "delete". NO! We're talking about 
 >counting lines between marks. T H A T    I S    A L L; Now go crawl back 
 >to wherever you came.
 
 >For the benefit of *your* reality I'd suggest following the discussion 
 >more closely.

Try it yourself.  The issue of line counting came up because the
original flamer didn't know how to delete a block of text without
counting the lines on his fingers.  You changed the subject, and
are now flaming people who understood it in the first place.

	Chuck Karish	hplabs!hpda!mindcrf!karish	(415) 493-7277
			karish@forel.stanford.edu

jdc@naucse.UUCP (John Campbell) (03/26/89)

From article <22244@shemp.CS.UCLA.EDU>, by gast@lanai.cs.ucla.edu (David Gast):
| In article <24@hcr.UUCP> stacey@hcrvax.UUCP (Stacey Campbell) writes:
|>    :'a,'bd
|>
|>or if the cursor is at the end of the range for deletion...
|>
|>    :'a,.d

| delete whole lines (that is what the above command does), you can just
| type d'a   (only 3 strokes).
| 
| then you should type d`a

But I'm in an "alternate" file (#) and I want to Yank to a named buffer so
I can go back and put the text in place.  One of the things that bothers
me about vi is it's lack of orthogonality (symmetry?).  I think I tried
Y'a"a, "aY'a, etc. and none of my attempts to extend "d" to "Y" seemed
to work.  Am I wrong or does anyone have further comments?
-- 
	John Campbell               ...!arizona!naucse!jdc
                                    CAMPBELL@NAUVAX.bitnet
	unix?  Sure send me a dozen, all different colors.

gast@lanai.cs.ucla.edu (David Gast) (03/26/89)

In article <4129@ttidca.TTI.COM> kevin@ttidcb.tti.com (Kevin Carothers) writes:
>In article 601 <24@hcr.UUCP>
>From: stacey@hcr.UUCP (Stacey Campbell)
>
>There are many reasons why one needs to count lines 
>between marks for other than deleting [ie; the ">>", "<<", "!}", etc.]. 
>What I presented was the *ONLY* way I know of to "C O U N T    L I N E S 
>without having to count. How many times do I have to repeat myself!

I guess you will have to repeat yourself, until you read what others write
and you learn another way.  Turn your flame gun off, read and learn!

You have still missed the point.  You do not need to count the lines in 
these cases.  Just use the objects.  Suppose you want to indent all lines
up to (not including) the line beginning with /pattern.  Then you type:
>/^pattern<cr>.  (In most cases, you probably will not need the ^, but it
is there in case it is necessary).  If you want to include the line with
pattern, then you type: >/attern<cr> (assuming that attern is only in that
one line; if you get bad results, you undo and choose a different
pattern).  Please note, it is not necessary to count lines.  You do not
have to type: 27>> You could also use the substitute command and you
would not have to count lines then either, but the above way is less
typing.

Your other example ``!}'' makes no sense at all.  This command goes from the
current position to the end of paragraph.  Why do you need to know the
number of lines to use this command?  If you want to sort all the lines
until the pattern, you can type: !/pattern<cr>sort<cr>.  The same rule about
pattern as above applies.  That is, if the pattern starts a line, then
that line is not included, otherwise it is.

These methods are clearly faster than yours.

>>>'a,'bw! wc -l

1) You do not have to mark a, then go to b and mark it.
2) You do not have to fork a shell to count lines.
3) Even after you have done the above, you still have not done the real
   command you want to do (delete, change, yank, indent, etc).

I am not saying that there cannot be some reason why you have to count
lines, but I have not seen you provide one yet.  Lots of alternatives
have been suggested including ``make an estimate, and undo it if it is
wrong.''

Before flaming again, read the other messages and LEARN that you do NOT
HAVE TO COUNT.  If you want to count when that is not necessary, feel
free, but do not keep telling the net that it is necessary to count.  It
is not.

David Gast
gast@cs.ucla.edu
{uunet,ucbvax,rutgers}!{ucla-cs,cs.ucla.edu}!gast

chris@mimsy.UUCP (Chris Torek) (03/26/89)

>But I'm in an "alternate" file (#) and I want to Yank to a named buffer so
>I can go back and put the text in place. ...  I think I tried
>Y'a"a, "aY'a, etc. and none of my attempts to extend "d" to "Y" seemed
>to work.  Am I wrong or does anyone have further comments?

Y (uppercase) is shorthand for `yy', yank-the-current-line.  You
need to use

	"ay'a

to yank from here to the line marked by mark-a into buffer-a.  If
you want a character-oriented yank (from here to mark-a) use "ay`a.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

stacey@hcr.UUCP (Stacey Campbell) (04/06/89)

In article <4129@ttidca.TTI.COM> kevin@ttidcb.tti.com (Kevin Carothers) writes:
>In article 601 <24@hcr.UUCP> stacey@hcr.UUCP (Stacey Campbell)
>
>>You gotta see this to believe it, truly a case of the moronic
>>leading the blind.
>
>You are flaming me for something which is *YOUR* misconception.

Wrong.

The original question by the beginner user was "I want to delete lines
in vi, but I need to know an easy way to count the lines for deletion?"
This implies that user knew only one way to delete lines in vi, namely

	[integer]dd

So you, my extremely misguided friend, offer;

	'a,'bw! wc -l

to achieve the calculation of the integer.  This amounts to a
minimum of two execs and one fork (more likely two) to count
a range of marked lines so that a value can be prefixed to dd.

Obviously an extremely expensive and stupid way to delete lines.

>For the benefit of *your* reality I'd suggest following the discussion 
>more closely.

It is obvious you have failed utterly to follow the discussion,
I suggest you closely read all articles before you attempt to flame
lest you look even more like a twit.
-- 
Stacey Campbell, HCR Corporation, {lsuc,utzoo,utcsri}!hcr!stacey

tchrist@convex.COM (Tom Christiansen) (11/16/89)

In article <1989Nov15.202718.12762@ux1.cso.uiuc.edu> mcdonald@aries.scs.uiuc.edu (Doug McDonald) writes:
|The problem with using vi is not LEARNING it, it is using it. LEarning
|is easy. Using is impossible: its command structure is broken,
|hopeless beyond any hope of repair. Consider this: start typing
|in something (after hitting "i" of course) then step mout for a Coke. 
|Come back: your cursor is in the middle of the page. Are you in 
|insert mode or not? Start typing - DAMMIT - oops, I forgot that
|I really DID hit escape before going for that Coke. Utter mess
|ensues.

Well, if your vendor is too inconsiderate to add the "show insert"
option (which I possess but disdain using -- I always seem to know
where I am), and you're too dumb to know to type ESCAPE when you
forget where you are, then you deserve anything you get.  

Note the followup line and take the religious flames elsewhere.
Some people enjoy the constructive, educational discussions that 
take place in this newsgroup.  

--tom


    Tom Christiansen                       {uunet,uiucdcs,sun}!convex!tchrist 
    Convex Computer Corporation                            tchrist@convex.COM
		 "EMACS belongs in <sys/errno.h>: Editor too big!"