【问题标题】:VIM: exit insert mode with :normal commandVIM:使用 :normal 命令退出插入模式
【发布时间】:2011-04-29 23:32:27
【问题描述】:

例如,当我使用 :normal 命令 (:normal i) 进入插入模式时,如何退出插入模式?

如果我按 ,VIM 退出命令模式,我无法运行我的 :normal 命令。

我将imap <c-e> <Esc> 放在我的.vimrc 中,但是当我在命令模式下输入 时,没有插入任何内容。我不知道如何在命令模式下输入“control e”。

有效,例如:normal Ihello<c-o>Aworld,但有时我想在正常模式下执行多个命令。

我知道我可以使用宏,但我想知道如何使用 :normal。

【问题讨论】:

    标签: vim macvim


    【解决方案1】:

    要在命令中添加文字<ESC>,在插入模式下,按CTRL+V,然后按<ESC>

    :help i_CTRL-V

    【讨论】:

      【解决方案2】:

      :imap 不会在命令模式下触发。使用:cmap 或更好的:cnoremap

      正如太多 php 所说,CTRL-V 可以在插入模式或命令行编辑中插入原始字符。

      【讨论】:

        【解决方案3】:

        可维护的解决方案是:

        exe "normal! Ihello\<c-o>Aaworld\<esc>"
        

        ...:h :normal

        【讨论】:

          猜你喜欢
          • 2023-03-28
          • 1970-01-01
          • 2018-08-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-09-18
          • 1970-01-01
          相关资源
          最近更新 更多