Skip to content

Instantly share code, notes, and snippets.

@xuchunyang
Created January 3, 2015 06:08
Show Gist options
  • Save xuchunyang/609cf66dd98309d048b8 to your computer and use it in GitHub Desktop.
Save xuchunyang/609cf66dd98309d048b8 to your computer and use it in GitHub Desktop.
Copy or Paste using one and the same key ("C-c c")
;;; Copy or Paste using one and the same key ("C-c c")
(defun copy-or-paste ()
"Copy when there are selected text, paste otherwise."
(interactive)
(if (region-active-p)
(copy-region-as-kill (region-beginning) ; Copy
(region-end))
;; TODO: deactive mark/region
;; Paste
(yank)))
(global-set-key (kbd "C-c c") 'copy-or-paste)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment