1

Question inspired by this answer:

Is there a way to configure vim so, that in insert mode moving the cursor outside currently edited area (cursor keys, ctrl-o prefix, whatever) will return to normal mode, but just editing the currently inserted text will stay in insert mode?

How?

Alternatively, how to prevent cursor from leaving the currently inserted text in insert mode, requiring Esc first.


Some examples to clarify:

ibsr<left><bs>a<right>

stays in insert mode, but

ibar<up>
iba<left><left><left>
iba<right>

would all return to normal mode.

4

1 回答 1

2

没有快速简便的内置配置。最接近的是 的默认(空)值,'backspace'它不允许<BS><Del>和当前插入之外。<C-W><C-U>

也就是说,没有什么能阻止您编写自定义插件。它必须使用:inoremap <expr>所有移动键(如<Left>,<Up>等)并测试离开当前行的光标/您认为当前编辑的任何内容(不幸的是,'[and']标记仅在插入模式离开后设置),然后返回原始键有条件地后跟<Esc>.

可行,但相当投入。你真的需要编辑器给你那些训练轮子吗?编辑时的一点自我约束和反思应该已经教会你“正确”地使用 Vim。

于 2013-10-24T09:32:07.973 回答