V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
xiaozhu317
V2EX  ›  Vim

使用 Vim 的时候遇到了一点问题

  •  
  •   xiaozhu317 · 31 天前 · 1175 次点击

    https://i.imgur.com/NrtkwmW.gif

    如上图,我首先使用了 yiw yank 了 color 单词,然后我想把后面的单词都粘贴为 color ,可是我每次在 Visual 模式下粘贴,都会使用上次被覆盖的单词,层层递进一样???

    我整个系统全是这样的情况,idea-vim ,vscode-vim 都是这样的情况。

    我在之前的使用过程,没有这样的情况啊? 是我自己的电脑有问题吗?

    12 条回复    2024-08-19 09:56:53 +08:00
    albertsteve11100
        1
    albertsteve11100  
       31 天前
    你 yiw 复制的单词会寄存在"这个 register 里面,之后你做的其他关于删除的操作也会默认寄存在"这个 register 里
    可以"ayiw 把单词复制到 a 这个 register 里,然后"ap 粘贴 register
    zeal7s
        2
    zeal7s  
       31 天前
    idea-vim 里可以加上如下配置
    vnoremap p "_dhp
    droppedbytech
        3
    droppedbytech  
       31 天前   ❤️ 1
    用大写的 P ,不要用小写的,visual 模式下小写的 p 会同时把你选中的 visual 文本放进 unnamed 寄存器中(如果你设置过 clipboard 的行为的话,剪贴板的内容也会换)。以下内容出自:h v_p
    ```
    With |p| the previously selected text is put in the unnamed register (and
    possibly the selection and/or clipboard). This is useful if you want to put
    that text somewhere else. But you cannot repeat the same change.
    With |P| the unnamed register is not changed (and neither the selection or
    clipboard), you can repeat the same change. But the deleted text cannot be
    used. If you do need it you can use |p| with another register.
    ```
    ho121
        4
    ho121  
       31 天前
    yiw yank 了 color 单词,后面第一次 p 可以直接粘贴为 color ,再次粘贴可以试试 "0p 这个组合(英文引号、数字 0 、字母 p )
    bnrwnjyw
        5
    bnrwnjyw  
       31 天前
    楼上说的都对,你学习下寄存器相关知识就明白了。
    xiaozhu317
        6
    xiaozhu317  
    OP
       31 天前
    @bnrwnjyw 嗯嗯,也是一步一步的学习 Vim ,今天遇到问题了,也就学到新的知识了
    xiaozhu317
        7
    xiaozhu317  
    OP
       31 天前
    @droppedbytech 原来如此,感谢普及
    xiaozhu317
        8
    xiaozhu317  
    OP
       31 天前
    @zeal7s 可以的,这个设置起到作用了,感谢
    xiaozhu317
        9
    xiaozhu317  
    OP
       31 天前
    @albertsteve11100 vim 寄存器之前一直没去了解,感谢普及
    xiaozhu317
        10
    xiaozhu317  
    OP
       31 天前
    @zeal7s 这个应该就是把选中的 delete 并放入到黑洞寄存器,然后在 paste 是吧,学到了学到了
    xiaozhu317
        11
    xiaozhu317  
    OP
       31 天前
    @ho121 可以,正在研究适合自己的方法
    skt041959
        12
    skt041959  
       28 天前
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   881 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 20:14 · PVG 04:14 · LAX 13:14 · JFK 16:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.