Copying text outside of Vim with set mouse=a enabled

后端 未结 14 820
陌清茗
陌清茗 2020-12-07 06:54

After enabling set mouse=a, text copied inside of Vim will not paste outside of Vim. Does anybody know of a way to fix this?

Here, selecting text with t

14条回答
  •  攒了一身酷
    2020-12-07 07:24

    Use ", +, y after making a visual selection. You shouldn’t be using the terminal’s copy command anyway, because that copies what the terminal sees instead of the actual content. Here is what this does:

    • ",+ tells Vim to use the register named + for the next delete, yank or put. The register named + is a special register, it is the X11 clipboard register. (On other systems, you would use * instead, I think, see :help clipboard and :help x11-selection)
    • y is the yank command, which tells Vim to put the selection in the register named previously.

    You could map it like this:

    :vmap  "+y
    

    And then highlight something with the mouse and press Control-C to copy it.

    This feature only works when Vim has been compiled with the +xterm_clipboard option. Run vim --version to find out if it has.

提交回复
热议问题