最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vim - Return to normal mode when I stop typing - Stack Overflow

programmeradmin2浏览0评论

When I edit files in vim I mostly stay in the normal mode. To type text I go to the insert mode, but eventually I stop typing to "think". Usually, that's the moment when I need to hit <Esc>. How can I have vim automatically return to normal mode after I am idle in the insert mode for too long?

I know some remap <Esc> to ff, for convenience, but I would like to go back to normal mode automatically without having to hit any key at all.

When I edit files in vim I mostly stay in the normal mode. To type text I go to the insert mode, but eventually I stop typing to "think". Usually, that's the moment when I need to hit <Esc>. How can I have vim automatically return to normal mode after I am idle in the insert mode for too long?

I know some remap <Esc> to ff, for convenience, but I would like to go back to normal mode automatically without having to hit any key at all.

Share Improve this question asked Feb 17 at 2:57 Paweł WójcikPaweł Wójcik 3422 silver badges11 bronze badges 2
  • I think this may already have been done with some plugin somewhere... every time I think of something I assume I'm not the first to have come up with it or to have the need for it. – icedwater Commented Feb 17 at 3:33
  • 1 This one? – Robby Cornelissen Commented Feb 17 at 3:37
Add a comment  | 

2 Answers 2

Reset to default 6
augroup vimrc_example | au!
autocmd CursorHoldI * stopinsert
augroup end

Make sure to see :h CursorHoldI and :h 'updatetime' to understand how it works.

Note, however, that "usually" is too far away from "always", so such "auto-helpers" often bring more problems than they solve.

You could use stopinsert.nvim Neovim plugin => https://github/csessh/stopinsert.nvim

More complete than using an autocommand:

  • dedicated option for idle time before leaving Insert mode
  • disable plugin for specific filetypes
发布评论

评论列表(0)

  1. 暂无评论