y{motion} command question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

y{motion} command question

Alexei Alexandrov
Hi All!

Why y{motion} command always moves to the beginning of yanked block after yanking? For example, move to the line 3, press ma, move to the line 12, press y'a. The cursor moves to the line #3. Is there a way to get rid of this movement?

--
Alexei Alexandrov
Reply | Threaded
Open this post in threaded view
|

Re: y{motion} command question

Tim Chase-2
> Why y{motion} command always moves to the beginning of yanked
> block after yanking? For example, move to the line 3, press
> ma, move to the line 12, press y'a. The cursor moves to the
> line #3. Is there a way to get rid of this movement?

I'm not sure there's a way to prevent the motion.  However, you
can save yourself some of the marking by simply making use of the
">" mark which is the end of a visual the selection.  Thus, you
can just do

move to line 3
select visually to line 12
"y"ank
use `>  to jump back to the position on line 12


Alternatively, if you're yanking line-wise, you can do something
akin to what you did before:

move to line 3
press "ma" to mark the line as "a"
move to line 12
use the following Ex command:
     :'a,.y

This should preserve your position on line 12. It works here.
YMMV :)

Others may have some other ideas.  However, hopefully this gives
you some ideas to work with?

-tim






Reply | Threaded
Open this post in threaded view
|

RE: y{motion} command question

Keith Roberts
In reply to this post by Alexei Alexandrov
>-----Original Message-----
>From: news [mailto:[hidden email]] On Behalf Of Alexei Alexandrov
>Sent: Wednesday, May 25, 2005 11:09 AM
>To: [hidden email]
>Subject: y{motion} command question
>
>Hi All!
>
>Why y{motion} command always moves to the beginning of yanked
>block after yanking? For example, move to the line 3, press
>ma, move to the line 12, press y'a. The cursor moves to the
>line #3. Is there a way to get rid of this movement?
>
>--
>Alexei Alexandrov

Why would you?  You've *told* it to move to 'a ['a is the {motion}].

I think what you want is:   ma:.,12yy

[The ma can be omitted unless you really do want the mark there.]

Alternatively, `` will always get you back where you started the yank
from.

And lastly, there was a thread awhile back about this (or similar).
IIRC, if you want to use visual mode and always be positioned at the
"end" which is closest to the end-of-buffer, I believe someone made a
function for this.  

-Keith