ErgoEmacsEmacsLispBlogEmacsLispBuy Tutorial

Emacs: Clipboard History and Multiple Clipboards

, ,

{Copy, Cut, Paste} Keys

If you prefer standard keys for copy/paste, then turn on cua-mode. Put this in your init:

;; use standard keys for undo cut copy paste
(cua-mode 1)
namestandard keysemacs keysemacs name
undoCtrl+zCtrl+/undo
cutCtrl+xCtrl+wkill-region
copyCtrl+cAlt+wkill-ring-save
pasteCtrl+vCtrl+yyank

Paste from Clipboard History

Emacs's clipboard (called kill-ring) maintains a history of copy/cut content.

You can see your copy history in the menu 〖Edit ▸ Paste from kill Menu〗, or call describe-variable and type kill-ring.

You can paste previous copy content by calling yank-popAlt+y】 one or more times to insert from earlier history. Try this:

Visually Nagivate Clipboard History

There's a package browse-kill-ring.el that lets you visually navigate the kill-ring history. Install it from MELPA. 〔☛ A Guide on Emacs 24 Package System

Once installed, call browse-kill-ring to view copy history, and click or press Enter ↵ on a line to insert that entry. Or, you can add this to your init file:

;; invoke visual nagivation of clipboard history with emacs `yank-pop' (paste previous) key, when the key isn't preceded by paste command
(browse-kill-ring-default-keybindings)

Multiple Clipboards: Emacs Register

Sometimes you need to have a piece of text that you need to paste often. Let's say you have 2 pieces of text: {A, B}. You need to paste A in some places, paste B in other places.

Emacs has “registers” for this. It lets you store text in it.

Example use:

(register can also store cursor location, file path, …. (info "(emacs) Registers"))

One Keypress for Copy/Paste Register 1

See: Emacs Lisp: Single Key to Copy/Paste from Register.

blog comments powered by Disqus