[sf-lug] vim logic

Alex Kleider a_kleider at yahoo.com
Sun Feb 3 18:26:36 PST 2008


--- RBV <GoodWriter2548 at earthlink.net> wrote:

> > From: Alex Kleider <a_kleider at yahoo.com>
> > Subject: [sf-lug] beginner's vim question
> > 
> > I'm puzzled by the behavior of the - and + movement commands within
> > vim:
> > They are defined as "to the first non blank character" of the line
> > above/below the cursor.
> > When used alone, that indeed seems to be what they do.
> > BUT..
> > if used as a motion parameter to the d(elete command:
> > the deletion includes the line below or above AS WELL as the
> > appropriate part of the line on which the cursor was sitting.
> > 
> > This seems counter intuitive to me. Can anyone shed some light as
> to
> > why it's set up this way?
> > 
> > a_kleider at yahoo.com
> > 
> Alex:
> 
> Interesting question.  In trying to puzzle out the solution, I came
> upon a couple of paragraphs that seemed to be explaining the behavior
> on this page: http://vimdoc.sourceforge.net/htmldoc/motion.html 
> 
> "The operator either affects whole lines, or the characters between
> the start
> and end position.  Generally, motions that move between lines affect
> lines
> (are linewise), and motions that move within a line affect characters
> (are
> characterwise).  However, there are some exceptions.
> 
> ...and...
> 
> "A character motion is either inclusive or exclusive. When inclusive,
> the start
> and end position of the motion are included in the operation.  When
> exclusive,
> the last character towards the end of the buffer is not included. 
> Linewise
> motions always include the start and end position.
> 
> So, if I position the insertion point on a given line in the
> following text and in vim command mode
> press dj (delete and move down), vim deletes two lines.
> 
> Line 1
> Line 2
> Line 3
> Line 4
> Line 5
> 
> A bit confusing, yes, but it fits nicely into "vim-logic"...
> 
> Cheers & hope this helps,
> Riley


It'll take me a while to puzzle through that one but I will!
Thanks, Riley, for taking an interest.
And thanks for the ref.
alex.


a_kleider at yahoo.com


      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 





More information about the sf-lug mailing list