xiaozhu317
V2EX  ›  Vim

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

  •  
  •   xiaozhu317 · Aug 16, 2024 · 4143 views
    This topic created in 650 days ago, the information mentioned may be changed or developed.

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

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

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

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

    12 replies    2024-08-19 09:56:53 +08:00
    Stunt4013
        1
    Stunt4013  
       Aug 16, 2024
    你 yiw 复制的单词会寄存在"这个 register 里面,之后你做的其他关于删除的操作也会默认寄存在"这个 register 里
    可以"ayiw 把单词复制到 a 这个 register 里,然后"ap 粘贴 register
    zeal7s
        2
    zeal7s  
       Aug 16, 2024
    idea-vim 里可以加上如下配置
    vnoremap p "_dhp
    droppedbytech
        3
    droppedbytech  
       Aug 16, 2024   ❤️ 2
    用大写的 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  
       Aug 16, 2024
    yiw yank 了 color 单词,后面第一次 p 可以直接粘贴为 color ,再次粘贴可以试试 "0p 这个组合(英文引号、数字 0 、字母 p )
    bnrwnjyw
        5
    bnrwnjyw  
       Aug 16, 2024
    楼上说的都对,你学习下寄存器相关知识就明白了。
    xiaozhu317
        6
    xiaozhu317  
    OP
       Aug 16, 2024
    @bnrwnjyw 嗯嗯,也是一步一步的学习 Vim ,今天遇到问题了,也就学到新的知识了
    xiaozhu317
        7
    xiaozhu317  
    OP
       Aug 16, 2024
    @droppedbytech 原来如此,感谢普及
    xiaozhu317
        8
    xiaozhu317  
    OP
       Aug 16, 2024
    @zeal7s 可以的,这个设置起到作用了,感谢
    xiaozhu317
        9
    xiaozhu317  
    OP
       Aug 16, 2024
    @albertsteve11100 vim 寄存器之前一直没去了解,感谢普及
    xiaozhu317
        10
    xiaozhu317  
    OP
       Aug 16, 2024
    @zeal7s 这个应该就是把选中的 delete 并放入到黑洞寄存器,然后在 paste 是吧,学到了学到了
    xiaozhu317
        11
    xiaozhu317  
    OP
       Aug 16, 2024
    @ho121 可以,正在研究适合自己的方法
    skt041959
        12
    skt041959  
       Aug 19, 2024
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5335 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 113ms · UTC 08:07 · PVG 16:07 · LAX 01:07 · JFK 04:07
    ♥ Do have faith in what you're doing.