change.txt states that
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. This means that "yl" doesn't move the cursor, but "yh" moves the cursor one character left.
In Vi the "y" command followed by a backwards motion would sometimes not move the cursor to the first yanked character, because redisplaying was skipped. In Vim it always moves to the first character, as specified by Posix.
With a linewise yank command the cursor is put in the first line, but the column is unmodified, thus it may not be on the first yanked character.
Sure enough, if I have my cursor at
someVerySpecificSubclass and do a
yiw, the cursor will move to the start of the word.
I would like to yank this word without having the cursor move, because a lot of the time I want to change
someSubclass but I'll need
someVerySpecificSubclass somewhere else in the code.
This movement is not added to the jumplist, so I can't jump back with
CTRL-o. I can force adding it to the jumplist with
m', so I could
m'yiw<C-o>, but that is somewhat long (and I'm not sure how to map it properly).
In any case, it doesn't make sense to me that a yank operation would move the cursor at all.
- Yank a region in VIM without the cursor moving to the top of the block?
- Keep cursor from moving when yanking upwards
- Backward motions in Operator-pending mode move cursor
None of the solutions provided work for my use case, they all seem to assume you want the cursor to be placed at the end of the yanked text, not necessarily at the original position, which can (and in my case is) somehwere in the middle of the yanked text.