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
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
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-x have very fundamental roles in Emacs), but at least it's a decent interface design, just different from Emacs.
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: