For example, I have this in the buffer:
line1 .... A ....
line2 B
line3 .... C ....
Follow these steps:
- At first it's in Normal mode and the cursor is under
A
- Press
j
and the cursor will move toB
- Press
j
again and the cursor will move toC
Seems like internally Vim maintains a "user-expected" column position so when it goes from line2 to line3 it smartly restores the correct column position.
So how can I get the same behavior with Lua API (like vim.api.nvim_win_set_cursor()
) when moving the cursor one line down?
:normal! j
would probably work