I am writing a comment plugin that supports commenting in visual line mode. I tried using vim.cmd "stopinsert" for returning back to normal mode, but it doesn't work. How can I return back to normal mode?

1 Answer 1


I find out that I can do that with vim.api.nvim_input("<esc>"), but I am not sure if there is a better alternative

  • Beware that nvim_input is non-blocking Commented Dec 19, 2021 at 3:11
  • Have you found a better solution yet?
    – Myzel394
    Commented Nov 1, 2023 at 15:28

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.