real clipboard. You can't see this, unless you have
some application that shows the clipboard contents (e.g., KDE's Klipper).
Now select the other gvim, position the cursor somewhere and use the
Edit/Paste menu. You will see the text from the real clipboard is inserted.
USING BOTH
This use of both the "current selection" and the "real clipboard" might sound
a bit confusing. But it is very useful. Let's show this with an example.
Use one gvim with a text file and perform these actions:
- Select two words in Visual mode.
- Use the Edit/Copy menu to get these words onto the clipboard.
- Select one other word in Visual mode.
- Use the Edit/Paste menu item. What will happen is that the single selected
word is replaced with the two words from the clipboard.
- Move the mouse pointer somewhere else and click the middle button. You
will see that the word you just overwrote with the clipboard is inserted
here.
If you use the "current selection" and the "real clipboard" with care, you can
do a lot of useful editing with them.
USING THE KEYBOARD
If you don't like using the mouse, you can access the current selection and
the real clipboard with two registers. The "* register is for the current
selection.
To make text become the current selection, use Visual mode. For example,
to select a whole line just press "V".
To insert the current selection before the cursor: >
"*P
Notice the uppercase "P". The lowercase "p" puts the text after the cursor.
The "+ register is used for the real clipboard. For example, to copy the text
from the cursor position until the end of the line to the clipboard: >
"+y$
Remember, "y" is yank, which is Vim's copy command.
To insert the contents of the real clipboard before the cursor: >
"+P
It's the same as for the current selection, but uses the plus (+) register
instead of the star "*" register.
==============================================================================
*09.4* Select mode
And now something that is used more often on MS-Windows than on X-Windows.
But both can do it. You already know about Visual mode. Select mode is like
Visual mode, because it is also used to select text. But there is an obvious
difference: When typing text, the selected text is deleted and the typed text
replaces it.
To start working with Select mode, you must first enable it (for MS-Windows
it is probably already enabled, but you can do this anyway): >
:set selectmode+=mouse
Now use the mouse to select some text. It is highlighted like in Visual mode.
Now press a letter. The selected text is deleted, and the single letter
replaces it. You are in Insert mode now, thus you can continue typing.
Since typing normal text causes the selected text to be deleted, you can not
use the normal movement commands "hjkl", "w", etc. Instead, use the shifted
function keys. <S-Left> (shifted cursor left key) moves the cursor left. The
selected text is changed like in Visual mode. The other shifted cursor keys
do what you expect. <S-End> and <S-Home> also work.
You can tune the way Select mode works with the 'selectmode' option.
==============================================================================
Next chapter: |usr_10.txt| Making big changes
Copyright: see |manual-copyright| vim:tw=78:ts=8:noet:ft=help:norl: