I want to restore the pos of cursor in terminal when I reopen the terminal:

  • If the mode was terminal mode before, it is easy to feed a 'a' to terminal to change from normal mode to terminal mode.
  • If the mode was normal mode before, record the pos of cursor and recover it after reopening the terminal

Now I get stuck in obtaining the mode when I press <c-\><c-n> and then to call restore or other functions. Cause after pressing <c-\><c-n>, the mode (output of mode()) will always be normal.

Is there some feasible methods?

1 Answer 1


patch 8.2.1978 provide special key <cmd> to avoid mode changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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