vim - 在 vim 中使用 block 选择从行尾删除

标签 vim

当我尝试在 vim 中使用块选择从行尾删除时出现异常行为。

所以假设我有一个这样的文本:

delete this char:x
and this:x
also this:x
and then this:x
lastly this:x

如果我想附加 y我能做到的每一行:
  • 使用 C-v 开始块选择
  • 选择所有带有 4j 的行
  • 使用 $ 转到行尾
  • 开始附加 A
  • 输入所需的文本 y

  • 为了得到:
    delete this char:xy
    and this:xy
    also this:xy
    and then this:xy
    lastly this:xy
    

    但如果我尝试删除 x在最后一步而不是追加我希望得到:
    delete this char:
    and this:
    also this:
    and then this:
    lastly this:
    

    虽然我最终得到:
    delete this char:
    and this:x:
    also this:x:
    and then this:x:
    lastly this:x:
    

    据我了解,它将第一行中的最后一个字符附加到所有其他行(在本例中为 : )而不是删除丢失的字符(在本例中为 x )。

    我可以用宏或替代品来做到这一点,但我不太明白这种行为背后的基本原理。有没有办法通过块选择来做到这一点?

    最佳答案

    你试过了吗:{range}normal ?这应该有效:

    :'<,'>normal $x
    

    ('<,'> 位是在您输入 : 时为您填写的。)

    关于vim - 在 vim 中使用 block 选择从行尾删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14165566/

    相关文章:

    macos - OSX-Terminal.app + vim + 日晒配色方案

    vim - 在 Google Colab 中退出插入模式

    vim - 如何在空文件(vim)中以可视 block 模式(Ctrl + v)选择矩形区域?

    qt - 如何在qtcreator中使用fakevim keymap运行qt项目?

    vim - 捕获中断/中断命令

    vim - vim 有 block 替换模式吗?

    ruby - 有没有办法在 Vim 中为 Ruby 设置良好的自动完成?

    禁用另一个 nmap 的 vim nmap

    c++ - VIM:浏览符号?如何?

    java - 如何在 vim + eclim 中显示 java 函数的参数?