来自VIM FAQ:
10.2. In insert mode, when I press the <Esc> key to go to command mode, the
cursor moves one character to the left (except when the cursor is on
the first character of the line). Is it possible to change this
behavior to keep the cursor at the same column?
No. It is not possible to change this behavior. The cursor is *always*
positioned on a valid character (unless you have virtual-edit mode
enabled). So, if you are appending text to the end of a line, when you
return to command mode the cursor *must* drop back onto the last character
you typed. For consistency sake, the cursor drops back everywhere, even if
you are in the middle of a line.
You can use the CTRL-O command in insert mode to execute a single ex
command and return back to insert mode without moving the cursor column.
Run Code Online (Sandbox Code Playgroud)
如果您想在.vimrc中更改此行为并且仅在EOL上向左移动,请参阅此 vim提示.
你的初始“状态”是错误的,这是你在插入模式下得到的:
bar[]
Run Code Online (Sandbox Code Playgroud)
在插入模式下,光标在字符之间,而在正常模式下光标位于字符上。当你离开插入模式,光标已经是一个性格:会不会是什么性格?插入模式光标左侧的还是右侧的?Vim 应该如何决定哪一边是好的?
一个提示是用于进入插入模式的命令:在离开插入模式之后i可能会将光标留在左侧,a也可能将其留在右侧。但是,将光标放在我们输入的最后一个字符右侧的字符上有什么意义呢?
无论如何,插入模式是专门插入文本的。i<Esc>或a<Esc>毫无意义且无实际用途。另一方面:
Lorem[] dolor sit amet.
Lorem ipsum[] dolor sit amet.
<Esc>
Lorem ipsu[m] dolor sit amet.
Run Code Online (Sandbox Code Playgroud)
比:
Lorem[] dolor sit amet.
Lorem ipsum[] dolor sit amet.
<Esc>
Lorem ipsum[ ]dolor sit amet.
Run Code Online (Sandbox Code Playgroud)
不是吗?