Copy and paste content from one file to another file in vi

后端 未结 18 1501
南方客
南方客 2020-12-04 05:02

I am working with two files, and I need to copy a few lines from one file and paste into another file. I know how to copy (yy) and paste (p) in the same file. But that doesn

18条回答
  •  长情又很酷
    2020-12-04 05:03

    These remaps work like a charm for me:

    vmap  "*y     " Yank current selection into system clipboard
    nmap  "*Y     " Yank current line into system clipboard (if nothing is selected)
    nmap  "*p     " Paste from system clipboard
    

    So, when I'm at visual mode, I select the lines I want and press Ctrl + c and then Ctrl + v to insert the text in the receiver file. You could use "*y as well, but I think this is hard to remember sometimes.

    This is also useful to copy text from Vim to clipboard.

    Source: Copy and paste between sessions using a temporary file

提交回复
热议问题