【问题标题】:Vim commands containing `r` cause me to replace包含 `r` 的 Vim 命令导致我替换
【发布时间】:2014-11-12 16:03:30
【问题描述】:

我正在使用 vim 和 python-mode 扩展,但我很难使用包含 r 的命令。它导致 vim 替换字符而不是执行我想要的命令。

这是 python 模式的 vim 文档所说的 -

let g:pymode_rope_organize_imports_bind = '<C-c>ro'

所以我正在做 CTRL-cro,但就像我说的,它正在替换我所在的任何字符信o

我错过了什么?

【问题讨论】:

  • 当你使用&lt;C-c&gt;以外的东西时它是否有效?这可能会导致 Vim 中止映射。
  • @IngoKarkat:它没有。同样的行为导致后续 r 将我光标下的字符替换为o
  • 我似乎在 Ubuntu 17.10 上遇到了同样的问题当我运行 :map Ctrl-c 我得到 o C @:call pymode#motion#select('^\s 类\s', 0)

标签: vim vim-plugin python-mode


【解决方案1】:

看起来你的映射没有被 Vim 解释,所以它只看到 Ctrl-c,默认情况下会中止当前操作,然后是替换命令 r(参见 :help r),然后是它的“参数”。

您可以检查映射是否使用:map &lt;c-c&gt; 定义。

如果定义正确,可能是您的终端直接处理 Ctrl-c 而没有将其传递给 Vim,如 Vim FAQ 20.5 - Why does mapping the key not work? 中所述。在这种情况下,您可以按照Vim FAQ 20.4 - I am not able to create a mapping for the key. What is wrong? 上的说明进行操作,特别是:

1) First make sure, the key is passed correctly to Vim. To determine if
   this is the case, put Vim in Insert mode and then hit Ctrl-V (or
   Ctrl-Q if your Ctrl-V is remapped to the paste operation (e.g. on
   Windows if you are using the mswin.vim script file) followed by your
   key.

   If nothing appears in the buffer (and assuming that you have
   'showcmd' on, ^V remains displayed near the bottom right of the Vim
   screen), then Vim doesn't get your key correctly and there is nothing
   to be done, other than selecting a different key for your mapping or
   using GVim, which should recognise the key correctly.

【讨论】:

  • 我这样做了,但 vim 无法识别绑定。因为这个插件的所有绑定都使用 这似乎很奇怪。我无法想象我必须重新映射所有内容。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-19
  • 2021-07-17
相关资源
最近更新 更多