在Vi中将内容从一个文件复制并粘贴到另一个文件 [英] Copy and paste content from one file to another file in vi

查看:903
本文介绍了在Vi中将内容从一个文件复制并粘贴到另一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理两个文件,我需要从一个文件复制几行并粘贴到另一个文件中。我知道如何在同一文件中复制(yy)和粘贴(p)。但这不适用于其他文件。

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't work for different files. How is this done?

还有,有什么方法可以剪切粘贴吗?我已经尝试过使用Google搜索,但是大多数资源都只讲复制粘贴。

Also, is there a way to cut-paste? I have tried googling, but most of the resources only talk about copy-paste.

推荐答案

因为您已经知道如何剪切/删除文本,以下是将其粘贴回另一个文件的一些想法:

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


  • 编辑第一个文件,提取所需的文本。然后从vi中打开第二个文件(:e / path / to / other / file )并粘贴

  • 在拆分窗口中一起打开两个文件,然后使用 Ctrl + w Up / Down 在两个文件之间导航:

  • 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

  • 在第一个文件中, Ctrl + w s

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

这篇关于在Vi中将内容从一个文件复制并粘贴到另一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆