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

后端 未结 18 1505
南方客
南方客 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:26

    Since you already know how to cut/yank text, here are a few ideas for pasting it back into another file:

    • Edit the first file, yanking the text you want. Then open your second file from within vi (:e /path/to/other/file) and paste it
    • Open both files together in a split window and navigate between them using Ctrl + w, Up/Down either by:

      • vi -o /path/to/file1 /path/to/file2
      • From within the first file, Ctrl + w, s

提交回复
热议问题