Cut or copy current line with easy-kill

I’ve previously written about how to cut the current line without selecting it, using some custom lisp code. I’ve since noticed that my recommended setup, prelude already deals with this in a nicer way by using the package easy-kill. If you don’t use prelude, then install easy-kill and add

(global-set-key [remap kill-ring-save] 'easy-kill)

to your emacs config file.

Once you have done this, then C-w with no region selected will cut (kill) the current line, and M-w with no region selected will copy the current line. This is one of those neat shortcuts I use all the time and miss whenever I have to edit text outside of emacs!

The easy-kill package also offers the easy-mark function, that expands highlighted regions by word, line or other useful units, but I prefer expand-region for this purpose.