Replacing a Region With the Last Kill

I learned a another neat trick from Aaron Hawley’s Giant Emacs Reference Sheet. This is another of those tricks, like the revert buffer shortcut, that uses keystrokes intended to do something else in a novel way to accomplish something unexpected.

In this case, we want to replace the current region with the last kill. Hawley says to do this with 【Ctrl+w Ctrl+y Meta+y】. This looks odd because the 【Ctrl+w】 is already a complete shortcut.

If you look at the entire sequence carefully, you see that it accomplishes the task in 3 steps:

  1. Ctrl+w】 kill the region
  2. Ctrl+y】 yank it back
  3. Meta+y】 replace the last yank with the penultimate kill

So it’s really just a matter of combining 3 commands to do something new. A very nice trick and easy to remember because it’s not really anything new.

This entry was posted in General and tagged . Bookmark the permalink.