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

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

    Enter command mode and run

    :r! sed -n ',  p' file_to_extract_text_from
    

    E.g to extract lines 20-30 from filename into the currently opened file

    :r! sed -n '20, 30p' filename
    

提交回复
热议问题