1

I want to copy just one character underneath the cursor. Its not ascii, so I can't type it. Is there a function or key that allows for this?

Vanilla emacs welcome, though evil and spacemacs answers are also acceptable.

1
  • I suppose you want to copy a char to insert it somewhere. If you know the char number, why not simply insert it where you want it to be ? M-:(insert-char (read-number "char: ") ) ? Or you can compose an interactive function to do it. If you don't know how to do it, ask for it
    – gigiair
    Feb 17 at 19:05
0

Three keys, as observed by view-lossage

 C-SPC                   ;; set-mark-command
 C-f                     ;; forward-char
 <escape> w              ;; kill-ring-save
2

You can add this function in your init file:

    (defun kill-ring-save-char-at-point ()
    "save the character at point in the kill-ring "
      (interactive)
      (unless (eq (point) (point-max))
        (kill-ring-save (point) (1+ (point)))))

and bind it to a key of your choice.

2
  • I like this answer, but I preferr to use motions already defined by emacs. Still, thanks! Feb 18 at 6:58
  • Perhaps it would be better to copy the characters to a register. C-SPC C-f C-x r s to record them then C-x r i to play them back.
    – gigiair
    Feb 18 at 10:15
0

spacemacs (evil): Copy: vy Paste: p

4
  • 1
    Welcome to Emacs.SE! Can you please explain your answer in more detail.
    – Dan
    Feb 17 at 12:02
  • v - visual mod. Char under cursor is already selected. Now "y" to copy end exit visual mod.
    – Hive
    Feb 17 at 18:36
  • 2
    Please edit your answer to add the material you put in your comment.
    – Dan
    Feb 17 at 20:08
  • This is my favorite, though it would be nicer if the comment was added to the full answer. Feb 18 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.