vi editing  «Prev 

Using named buffers to paste between files

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

2) Delete the first line, Grilled Salmon, and store it in a buffer name a
2) 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

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

4) Instead of going to the next file, vi displays the message "No write since last change."
4) 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.

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

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

7) 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.
7) 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

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