vim - 从 Vim 中的用户定义命令切换到 **插入** 模式

标签 vim

我正在我的 vimrc 中定义自己的命令:

command! Tcs :normal lvf`hc

目的是我继续反引号,它将删除从此处到下一个反引号的内部内容。喜欢:

`hi there` -> ``

问题是仍然处于正常模式,我想复制 c 命令行为,以便我可以在 插入 模式下立即开始输入。

我已经尝试过命令! Tcs :normal lvf`hc :startinsert 但我在最后一个 c 之后输入的任何内容都将直接在编辑器中输入。

谢谢

最佳答案

来自:help :normal >

        :norm[al][!] {commands}                   *:norm* *:normal*
        (...)
        {commands} should be a complete command.  If
        {commands} does not finish a command, the last one
        will be aborted as if <Esc> or <C-C> was typed.             

This implies that an insert command must be completed.

       (...)

在您的情况下,命令正常已被中止,这就是您仍处于正常模式的原因。您仍然可以尝试 :normal!我

要得到你想要的东西,你可以这样做:

command! Tcs execute "normal lvf`hd" | :startinsert

关于vim - 从 Vim 中的用户定义命令切换到 **插入** 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41805215/

相关文章:

vim - 在VIM中将mapleader设置为CTRL

vim - 如何禁用与自定义映射冲突的 NERDTree 映射?

vim - 在vim中,如何使用argdo append/插入文本?

Vim - 仅在当前行上查找模式

vim - 在 Vim 中复制行并附加几个字母

javascript - 在 vim 中扩展 Javascript 语法高亮

git - 在 git 的 vim 中突出显示未提交的代码

vim - 如何在 Tmux 中使用 ESC 禁用 Pane 切换

vim - 如何消除文本 "[n] lines folded"

ruby-on-rails - 如何在不锁定 MacVim 的情况下在 MacVim 中运行 Ruby 规范和/或测试?