I'm working in Ubuntu, but since the standard way of inserting unicode characters (Ctrl+Shift+U and, after that, the unicode code) doesn't work inside emacs, I've, in my .emacs
, some keystrokes for different unicode symbols which I use frequently, for example:
(global-set-key (kbd "C-c b") "☛")
and every symbol works fine, except the symbol §, which is replaced by a simple dash ("-") when I use the corresponding keystroke:
(global-set-key (kbd "C-c y") "§")
The question is, what does it make this symbol different for other symbols and how can I solve my problem?
First, Emacs checks if there's a minor mode key binding; If there isn't, then Emacs checks if there are any local keys set. Typically this local map is shared by the major mode of the current buffer. So if you want to add a key binding to python-mode , you can use local-set-key to do this.
Although only the Control and Meta modifier keys are commonly used, Emacs supports three other modifier keys. These are called Super, Hyper, and Alt. Few terminals provide ways to use these modifiers; the key labeled Alt on most keyboards usually issues the Meta modifier, not Alt.
"RET" is the Return key while emacs runs in a terminal. and run emacs in terminal, your keybinding will have no effect. But the problem is, by binding (kbd "RET") , you are also binding (kbd "C-m") , regardless you run emacs in terminal or GUI.
To reassign a keyConnect the keyboard that you want to configure. Select the Start button, and then select Microsoft Mouse and Keyboard Center. From the displayed list of key names, select the key that you want to reassign. In the command list of the key that you want to reassign, select a command.
global-set-key
usually expects a function, so this should work:
(global-set-key (kbd "C-c y") (lambda () (interactive) (insert "§")))
But you're better off using the excellent insert-char
function:
(global-set-key (kbd "<f2> u") 'insert-char)
It understands hex Unicode as well as text description (with completion and all). Just press TAB to see the completions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With