This Emacs Wiki page


‘C-a C-SPC C-e M-w’ copies the current line without the newline.

But it doesn't work to me. I'm using Emacs 26. Is there some other shortcut?

P.S. I use CUA keys in my Emacs

  • 1
    What does "not work" mean? The sequence of shortcuts means selecting the current line then copy, so it should work, you can test it from Emacs -Q. – xuchunyang Aug 8 '20 at 11:34
  • @xuchunyang How I use more shorter shortcut for this? – a_subscriber Aug 8 '20 at 11:53
  • You can use C-a C-S-e M-w if know you know (emacs) Shift Selection, however, you can also write a new command to do whatever you want and assign a shortcut to it, e.g., write your-copy-region-or-current-line and assign M-w. – xuchunyang Aug 8 '20 at 13:14
  • @xuchunyang I'm can't use C-a because this select whole content of buffer – a_subscriber Aug 8 '20 at 13:55
  • 3
    By default, C-a runs move-beginning-of-line, which moves point to the beginning of the line. – xuchunyang Aug 8 '20 at 14:09

The function

(defun my-line-save ()
  (let ((l(substring (thing-at-point 'line)0 -1)))
    (kill-new l)
    (message "saved : %s" l)))

can do the trick, just assign the keys of your choice

(local-set-key (kbd "C-c w") #'my-line-save)

or whatever keys you like.


C-a C-SPC C-e M-w does work in all versions of Emacs. The only reason it doesn't work for you is that you've changed the key bindings. If you're using a GUI Emacs, you can use home S-end C-insert or Home S-End M-w instead. This may or may not work in a terminal, depending on how the terminal passes function keys to Emacs.

I'm can't use C-a because this select whole content of buffer

This indicates that you're using some third-party package that emulates common line editing packages, badly. Selecting the whole buffer is an extremely uncommon action. It is bad interface design to bind it to an easily-accessible key. I recommend that you stop using this package.

If you want Windows-like key bindings like C-c/C-x/C-v for copy/cut/paste, Emacs provides CUA mode. I don't recommend using this package because it deviates from standard Emacs key bindings (in particular, C-c and C-x have very fundamental roles in Emacs), but at least it's a decent interface design, just different from Emacs.

  • I use CUA keys in my Emacs – a_subscriber Aug 8 '20 at 19:52

Use Shift Key Tip from the manual

To enter an Emacs command like C-x C-f while the mark is active, use one of the following methods: either hold Shift together with the prefix key, e.g., S-C-x C-f, or quickly type the prefix key twice, e.g., C-x C-x C-f.

For your specific example:

  • Original Key Chords C-a C-SPC C-e M-w
  • Updated Key Chords S-C-a C-SPC C-e M-w
  • It's to long keybinding – a_subscriber Aug 16 '20 at 9:45

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.