如何使用缓冲区从文件 1 复制(抽取)并粘贴(放入)文件 2?

How to copy (yank) from file 1 and paste (put) in file 2 in vi using buffer?

我想知道在 vi 编辑器中使用缓冲区从文件 1 复制数据并将数据粘贴到文件 2 的过程。

你能告诉我一步一步的过程吗?

怎么做?

来自 vi 手册:

6.5.6.3 Using Named Buffers

To repeatedly insert a group of lines in various places within a document, you can yank (or delete) the lines into a named buffer. You specify named buffers by preceding a command with double quotes (") and a name for the buffer. For example, to yank four lines into the named buffer a, type "a4yy. You can use several different buffers. For example, you might also delete text from one location and add it to several others. To delete 12 lines into the named buffer b, type "b12dd.

To insert the text, precede the p or P command with n, where n is the named buffer. For example, to insert the lines saved in buffer b, type "bP.

You can overwrite named buffers with new lines. The buffers are saved until you exit vi.

When you use named buffers, you can safely delete and yank other text without affecting the lines you have already saved in the named buffers -- unless, of course, you purposely overwrite the named buffer.

以防万一您真的不需要缓冲区内容...

那么你也可以直接做这样的事情 overwrite file2:

:4,12w file2

附加 类似的内容:

:5,20w >> file2

当然也可以使用其他标准 ex 线路寻址选项。