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:
- 【Ctrl+w】 kill the region
- 【Ctrl+y】 yank it back
- 【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.