2

I'm using spacemacs on a Mac OS X laptop with a UK keyboard and I want to be able to use Alt-3 (M-3) to insert the hash symbol #. I tried to add this function that I found on this SO answer without any luck.

;; Allow hash to be entered  
(global-set-key (kbd "M-3") (lambda () (interactive) (insert "#")))

Do I have to unset this key combination before trying to set it? Is there anything else in the spacemacs configuration that always overwrite my user defined configuration with the "Change the current window with window 3"? I'm used to add the hash symbol using that combination and I feel uncomfortable using anything else.

  • Rather than dealing with that issue on Emacs, I added the Australian keyboard on my Mac, so # was S-3 and then didn't change anything to the Emacs config. – Miyamoto Akira Aug 25 '17 at 11:09
  • I can't change my MacBook integrated keyboard. So this is not a viable solution to my problem. – sentenza Aug 25 '17 at 13:35
  • Sorry, didn't explain myself correctly. Not the physical keyboard. You can change it on the settings panel (you can have multiple layouts and change them in the fly). There are barely differences between the uk and aus layout, so having still the uk physical keyboard is barely noticeable – Miyamoto Akira Aug 25 '17 at 13:54
  • Actually as I wrote in the question itself I feel uncomfortable using something else than <kbd>Alt</kbd>-<kbd>3</kbd>, so I was looking for the correct way to configure Spacemacs to accept this custom keybinding. – sentenza Aug 25 '17 at 14:10
3

Another approach is set (setq-default mac-right-option-modifier nil) to your dotspacemacs/user-init and start to use the "right Option+3" key to write the '#' symbol.

Definition:

(defun dotspacemacs/user-init ()
  (setq-default mac-right-option-modifier nil)
)
  • 1
    Cheers @Joao. This approach is working and it solved all my issues. – sentenza Aug 29 '17 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.