Is there a simple way (i.e. without writing a script or elaborate keymap sequence) to Yank a group of lines and leave the cursor wherever the Yank was performed, as opposed to at the start of the block?

According to VIM's help: "Note that after a characterwise yank command, Vim leaves the cursor on the first yanked character that is closest to the start of the buffer." Line-wise seems to behave similarly.

This is a bit annoying for me since I tend to select a large region from top to bottom, Yank, and then paste near or below the bottom of the selected region. Today I'm setting a mark (m-x) just before Yank and then jumping back, but I suspect there may be a different Yank sequence that will do what I need.

I've searched SO and the web for this numerous times. There is so much existing "VIM shortcuts" material to wade through yet I've not found a solution to this one yet.

Can you give an example of a yank command that changes the cursor position?
–
Greg HewgillSep 27 '10 at 18:22

I'm on line 1 and press V to start Visual Line mode. I move down 10 lines and press y to yank the region. After that command I'm back at line 1. Maybe the "thing" I moved during select isn't a technically the cursor, noneless it is where I'd like to end up when the yank is done. (So maybe the question should have read "how do I move the cursor after...")
–
LVBSep 27 '10 at 18:38

@LVB, @Curt, no, this mapping does not really work great: if i yank from bottom to top, then my cursor will be moved back to bottom. Try mapping that @Greg Hewgill implicitly suggested: :vmap y ygv<Esc> . This one, really, works like a charm.
–
Dmitry FrankDec 30 '11 at 10:10

If you're using visual blocks (v), then after yanking the block you can use gv to re-select the same block (which also moves your cursor position back to where it was before yanking). If you then press Esc, the block is un-selected without moving the cursor.

Also of interest might be the ctrl-o command in visual block mode, which jumps between the start and end of the selected block.

Oooh, @Greh Hewgill, thank you, thank you very much! I tried to find the solution so long, and so many times i've seen suggestions like zigdon provided: trick with '], but it does not work properly: if i yank from bottom to top, then my cursor will be moved back to bottom. But now, after reading you post, i defined mapping :vmap y ygv<Esc> , and it works like a charm. Great thanks again.
–
Dmitry FrankDec 30 '11 at 10:03

I believe that this answer should take much more upvotes!
–
Dmitry FrankDec 30 '11 at 10:07

I found out that this mapping causes flashing, especially on large yanks. To avoid this, you can do this: :set lazyredraw
–
Dmitry FrankJan 10 '12 at 7:22