vrapper/vrapper — pull request #32 by keforbes (2011-12-10 05:56:15+00:00)
Title: Cleanup logic for moving cursor on yank

Vim has some crazy logic for when it moves the cursor on yank and when it doesn't. In general, the cursor always moves to the beginning of the selection. If the selection goes above the current cursor position, the cursor jumps to that position. If the selection starts at the cursor and goes below, the cursor stays where it is.

The one notable exception to this is line-wise yanking. 'yy' leaves the cursor alone. 'yk' moves the cursor up a line but keeps the same column position. 'yj' leaves the cursor alone.

This fix simplifies vim's logic but I believe it handles ~90% of the cases. If we're in TEXT selection mode, always move the cursor to the beginning of the selection. If we're in LINES selection mode, always move the cursor to the first line in the selection but preserve the column. If we're in VisualMode, always move the cursor to the beginning of the selection.

This fix invalidates the option 'moveonyank' which we had defined to provide an all-or-nothing solution for moving the cursor. I have removed this option.

Please fire up vim, play with yanking text objects, then perform the same yank operation on this Pull Request. I think I cover enough cases that this solution is worth pulling into vrapper.