f register (f for First): >
"fyas
The "yas" command yanks a sentence like before. It's the "f that tells Vim
the text should be placed in the f register. This must come just before the
yank command.
Now yank three whole lines to the l register (l for line): >
"l3yy
The count could be before the "l just as well. To yank a block of text to the
b (for block) register: >
CTRL-Vjjww"by
Notice that the register specification "b is just before the "y" command.
This is required. If you would have put it before the "w" command, it would
not have worked.
Now you have three pieces of text in the f, l and b registers. Edit
another file, move around and place the text where you want it: >
"fp
Again, the register specification "f comes before the "p" command.
You can put the registers in any order. And the text stays in the register
until you yank something else into it. Thus you can put it as many times as
you like.
When you delete text, you can also specify a register. Use this to move
several pieces of text around. For example, to delete-a-word and write it in
the w register: >
"wdaw
Again, the register specification comes before the delete command "d".
APPENDING TO A FILE
When collecting lines of text into one file, you can use this command: >
:write >> logfile
This will write the text of the current file to the end of "logfile". Thus it
is appended. This avoids that you have to copy the lines, edit the log file
and put them there. Thus you save two steps. But you can only append to the
end of a file.
To append only a few lines, select them in Visual mode before typing
":write". In chapter 10 you will learn other ways to select a range of lines.
==============================================================================
*07.6* Viewing a file
Sometimes you only want to see what a file contains, without the intention to
ever write it back. There is the risk that you type ":w" without thinking and
overwrite the original file anyway. To avoid this, edit the file read-only.
To start Vim in readonly mode, use this command: >
vim -R file
On Unix this command should do the same thing: >
view file
You are now editing "file" in read-only mode. When