I am trying to make emacs function somewhat like sublime text, where C-x
cuts text that is selected and cuts the whole line when nothing is selected. I got the full-line cut to work using
(global-set-key (kbd "C-x") 'kill-whole-line)
but I'm not sure how to get C-w
's functionality (kill-region
) to happen when text is selected and then use C-x
. Is there a way to say something like
(if region-selected
('kill-region)
('kill-whole-line))
(And yes, I know I'm rebinding C-x
, but I'm sick of trying to switch mental muscle memory modes from sublime text to terminal editing.)