在 vi 中将内容从一个文件复制并粘贴到另一个文件 [英] Copy and paste content from one file to another file in 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?
另外,有没有办法剪切粘贴?我试过谷歌搜索,但大部分资源只谈复制粘贴.
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 中将内容从一个文件复制并粘贴到另一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!