Maybe something like this:
(global-set-key (kbd "<kp-1>") "1")
(keyboard-translate ?1 ?!)
I would actually use xmodmap
to change the keys across the whole
system, not just Emacs.
题
Just coming to Emacs from vi.
I'd like to rebind all the numbers across the top of the keyboard to their shifted counterparts (i.e. 1 maps to !, 2 maps to @, etc), while at the same time keeping the numerical keypad numbers as simply numbers.
I remapped the numbers just fine, and the numbers across the top of the keyboard map to symbols correctly; however this also maps the keypad numbers to symbols. In response I tried to remap the keypad numbers back to numbers again but this is unsuccessful - they stay as symbols.
This was straightforward and easy to accomplish when I was using vi, but I would prefer to keep using Emacs. Anyone have a solution?
Sample .emacs:
(global-set-key "1" "!")
; etc...
(global-set-key [kp-1] "1")
; etc...
解决方案
Maybe something like this:
(global-set-key (kbd "<kp-1>") "1")
(keyboard-translate ?1 ?!)
I would actually use xmodmap
to change the keys across the whole
system, not just Emacs.
其他提示
Try this:
(global-set-key "1" "!")
(global-set-key [kp-1] (lambda () (interactive) (insert "1")))
P.S. I use (lambda () (interactive) ...) in global-set-key
frequently and create alias for it:
(defmacro ilam (&rest body)
"Interactive lambda"
`(lambda ()
(interactive)
,@body))