How to Move Regions of Text (Cut & Paste)


The following emacs commands will allow you to move around regions of text without the use of a mouse.

Ctrl-<space> or Ctrl-@
Either of these commands will set a mark. A mark is an an invisible pointer which will be used to mark the starting character of the region you wish to delete or move. If you place the mark in the wrong place, you can set it elsewhere with the same command.
Ctrl-w
This command will kill all of the text between the mark location and the current emacs cursor position. This text can be retrieved with the following command unless you kill another block of text.
Meta-w
This command will save all of the text between the mark location and the current emacs cursor position; it can then be retrieved with the following command unless you kill/save another block of text.
Ctrl-y
This command will yank back the text which was deleted most recently with the above command. The text will be placed at the current emacs cursor location. You can yank back the text as many times as you wish.
Meta-y
When you kill or copy a region of text, it doesn't forget about previous kills. Instead, it keeps track of them in a stack fashion. If you want to yank the region you killed before the last one, hit Ctrl-y to yank, and then Meta-y to yank the previous kill instead of the one you just retrieved. You can keep hitting Meta-y as many times as you like, if you want to recover something killed a while back. The maximum number of kills remembered at any given time defaults to 30.
Ctrl-x u
This is the undo command. This is useful if you yank back text at the wrong location or sometimes if you delete something you didn't mean to. Each time you repeat this command, emacs will undo a previous change to your file.