Why does y8j
not move the cursor but y8k
does move it up?
What .vimrc entry would prevent yanking upwards moving the cursor?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityWhy 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'
.