next up previous
Next: Searching incrementally Up: emacs Previous: Emacs C++ mode coding

Cutting and pasting

To cut or copy a portion of your document, you first have to select the text that is to be cut. There are a variety of ways to do this. The keyboard way and the mouse way.

The keyboard way starts by setting the mark on the first character to be cut. Position the cursor on that character and type C-<spacebar>. That is hold down the Control key and hit the spacebar. You should see the confirmation message``Mark set'' in the command minibuffer. Then move the cursor to a position immediately after the last character to be cut. The region is implicitly ``selected''. The command C-w cuts the text and puts it in the invisible ``kill ring'', i.e. paste buffer. The command M-w copies the text to the kill ring, but doesn't delete it. To restore the text, use the command C-y. The text is copied to the position immediately before the cursor. If you made a mistake, you can also use C-x u to undo the cut.

The mouse way is much simpler. Left-drag with the mouse to highlight the selected region. Then double right-click to cut. Move the cursor to the paste position and click with the middle mouse button. If you just want to copy, don't do the double right-click.

There is a second mouse way to select a region, which is particularly useful when you are selecting a large portion of your file. Left-click with the mouse on the first character. Then right click immediately to the right of the last character. Complete the operation as before.

The kill ring is also populated when you delete text with C-k or M-d. So you can use C-y to paste text deleted in that manner as well. The kill ring consists of multiple paste buffers arranged in a circle. The ring starts with no paste buffers. Each time you kill or copy text, a new paste buffer is added to the ring next to the previous paste buffer. If you restore text with C-y you first get the contents of the most recent paste buffer. You can then use the M-y command to replace the restored text with the contents of the immediately previous paste buffer. Repeated M-y's cause the ring to cycle back through the paste history until you return to the most recent one.


next up previous
Next: Searching incrementally Up: emacs Previous: Emacs C++ mode coding
Carleton DeTar 2016-12-29