emacs how to define hotkey C-u to Delete from current position to the beginning of line

StackOverflow https://stackoverflow.com/questions/19042999

  •  29-06-2022
  •  | 
  •  

문제

I hava know C-u 0 C-k could do that thing, but I really want use C-u delete from current position to the beginning of line just like the bash readline.

도움이 되었습니까?

해결책

No, you really don't want to do that -- trust me. C-u is far too important in Emacs to be used for something else. And to substitute a different key for what C-u does would be a pain and troublesome for you in the end, IMHO.

Instead, find some other key that you're comfortable with and assign that to a command that does what you want. For example, rebind a key that is already bound to a command that you don't really care about (e.g. M-k).

For example:

(defun kill-to-bol ()
  "Kill text from point to beginning of line."
  (interactive)
  (kill-region (point) (line-beginning-position)))

(global-set-key "\M-k" 'kill-to-bol)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top