DistributedNetworks DistributedNetworks


vi editing  «Prev 

Using named buffers to paste between files

Assuming that you entered the command, vi recipe quartet, you can start editing the recipe file as shown
Assuming that you entered the command, vi recipe quartet, you can start editing the recipe file as shown

Delete the first line, Grilled Salmon, and store it in a buffer name a
Delete the first line, Grilled Salmon, and store it in a buffer name a.
To do that, type add as the command sequence. The result appears in this image

You plan to paste the buffer contents into the next file, so you use the :n command to go there.
You plan to paste the buffer contents into the next file, so you use the :n command to go there.

Instead of going to the next file, vi displays the message "No write since last change."
Instead of going to the next file, vi displays the message "No write since last change." That is because you did not save before leaving the current file. A common mistake when editing multiple files.

Enter :w to save the recipe file.
Enter :w to save the recipe file.

This time, the :n command takes you to the quartet file as you expect.
This time, the :n command takes you to the quartet file as you expect.

To put the contents of buffer above the line, type a P as the command sequence. Now the Grilled Salmon appears at the top line.
To put the contents of buffer above the line, type a P as the command sequence. Now the Grilled Salmon appears at the top line.
p: put (paste) the line(s) in the buffer into the text after the current line

When you are ready to leave vi, enter :wq to write and quit.
When you are ready to leave vi, enter :wq to write and quit.