In a vi editing session, your last deletion
x) or yank (
y) is saved in a buffer.
You can access the contents of that buffer and put the saved text
back in your file with the put command (
A frequent sequence of commands is:
5dd delete 5 lines move somewhere else p put the 5 deleted lines back in a new location, below the current line
What fewer new users are aware of is
that vi stores the last
immediately after you've made the deletion.
vi also allows you to yank (copy) text to "named" buffers identified by letters. You can fill up to 26 (a-z) buffers with yanked text and restore that text with a put command at any time in your editing session. This is especially important if you want to transfer data between two files, because all buffers except named buffers are lost when you change files. See article 30.5.
- from O'Reilly & Associates' Learning the vi Editor, Chapter 4