Prevent cursor from moving back one character on insert mode exit

前端 未结 6 1371
南笙
南笙 2020-11-29 21:35

...how would you do it?

task for extra credit: figure out a way to force vim to refresh the cursor position immediately after exiting insert mode

6条回答
  •  悲&欢浪女
    2020-11-29 22:10

    Based on Nathan Neff's comment, the best approach I've found is

    autocmd InsertLeave * :normal `^
    set virtualedit=onemore
    

    autocmd moves the cursor back to where it was when insert mode ended (i.e. one forward compared to the default).

    virtualedit makes it act consistently at end of line (so it can be one forward of the last character on the line).

提交回复
热议问题