简体   繁体   English

VIM:使用 :normal 命令退出插入模式

[英]VIM: exit insert mode with :normal command

When I go into insert mode with the :normal command ( :normal i ) for example, how do I exit insert mode?例如,当我使用 :normal 命令 ( :normal i ) 进入插入模式时,如何退出插入模式?

If I press <Esc>, or <cc>, or <c-[>, VIM exits command mode and I can't run my :normal command.如果我按下 <Esc>、或 <cc>、或 <c-[>,VIM 会退出命令模式并且我不能运行我的 :normal 命令。

I put imap <ce> <Esc> in my .vimrc but when I type <ce> in command mode, nothing gets inserted.我将imap <ce> <Esc>放在我的 .vimrc 中,但是当我在命令模式下键入 <ce> 时,没有插入任何内容。 I can't figure out how to enter a "control e" in command mode.我不知道如何在命令模式下输入“控制 e”。

<co> works, for example :normal Ihello<co>Aworld but sometimes I want to do more than one command in normal mode. <co> 有效,例如:normal Ihello<co>Aworld但有时我想在正常模式下执行多个命令。

I know I can use a macro, but I want to know how to do it with :normal.我知道我可以使用宏,但我想知道如何使用:normal。

To add a literal <ESC> to your command, while in insert mode, press CTRL+V then <ESC> .要将文字<ESC>添加到您的命令中,请在插入模式下按CTRL+V然后按<ESC>

See :help i_CTRL-V .请参阅:help i_CTRL-V

The maintainable solution would be:可维护的解决方案是:

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

... :h :normal ... :h :normal

:imap will not trigger in command mode. :imap不会在命令模式下触发。 Use :cmap or better, :cnoremap .使用:cmap或更好的:cnoremap

And as too much php said, CTRL-V makes it possible to insert raw characters in insert mode or command line editing.正如 php 所说的那样,CTRL-V 可以在插入模式或命令行编辑中插入原始字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM