在 Vim 中如何在命令和插入模式之间切换?

我刚开始把 Vim 用作 IDE。我用它作为测试编辑器已经有一段时间了,所以我不必经常使用命令模式。但是,因为我用 Java 编程,所以我必须进入命令模式来创建文件,编译/运行它... 等等。

问题是: 我需要一个在两种模式之间切换的好方法。

我上网查了一下,上面说 <Esc>键应该可以做到这一点,但是这对我来说不起作用(也许它不适用于 gVim?我不知道为什么。)

我必须按 CTRLO每次进入命令模式; 转义键工程从该模式... 它带我回到插入模式。但是,在命令模式和插入模式之间切换有更好或更简单的方法吗?

234755 次浏览

Pressing ESC quits from insert mode to normal mode, where you can press : to type in a command. Press i again to back to insert mode, and you are good to go.

I'm not a Vim guru, so someone else can be more experienced and give you other options.

Looks like your Vim is launched in easy mode. See :help easy.

This happens when Vim is invoked with the -y argument or as evim, or maybe you have a :set insertmode somewhere in your .vimrc configuration. Find the source and disable it; temporarily this can be also done via Ctrl + O :set noim Enter.

Using jj

In my case, the .vimrc (or in gVim it is in _vimrc) setting below.

inoremap jj <Esc>   """ jj key is <Esc> setting

This has been mentioned in other questions, but ctrl + [ is an equivalent to ESC on all keyboards.

There is also one more solution for that kind of problem, which is rather rare, I think, and you may experience it, if you are using vim on OS X Sierra. Actually, it's a problem with Esc button — not with vim. For example, I wasnt able to exit fullscreen video on youtube using Esc, but I lived with that for a few months until I had experienced the same problem with vim.

I found this solution. If you are lazy enough to follow external link, switching off Siri and killing the process in Activity Monitor helped.

Coming from emacs I've found that I like ctrl + keys to do stuff, and in vim I've found that both [ctrl + C] and [alt + backspace] will enter Normal mode from insert mode. You might try and see if any of those works out for you.

You can use Alt+H,J,K,L to move cursor in insert mode.

For me, the problem was that I was in recording mode. To exit from recording mode press q. Then Esc worked as expected for me.