Why does y8j not move the cursor but y8k does move it up?

What .vimrc entry would prevent yanking upwards moving the cursor?


In general, for commands that involve {motion}, the cursor is placed at the beginning of the resulting text area. y8j starts at the current position and moves down, so the cursor does not move. y8k only includes the current line as the last yanked one, so it moves the cursor to the first yanked line, i.e. up. The same happens with motions inside a single line, e.g. y8w (does not move) / y8ge (moves, as start is before cursor) / yiw (moves if the cursor is inside the current word vs. at the start of it).

To return the cursor to the original position, you can explicitly set a mark and return to it after the yank: m'y8k``. Some jump-motions automatically record a jump (but not k), so you can skip the m'.

  • Ah okay that makes way more sense thatn I thought. Thank you for the great answer! – jaaq Dec 6 '19 at 8:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.