I'm using emacs on MacOS (v11.4 Big Sur) installed from homebrew-emacs-plus and, every time I want to open a file for a quick edit on the terminal (on iTerm2) using emacsclient, a character gets inserted at the beginning the file (please check the attached image).

Other function keys like delete also insert sequences like [3~] and, I know there must be a simple solution I can find a direct reference to this.

How can I fix this so that I can do quick edits on directly on my terminal?


enter image description here

  • 1
    If you start your emacs with emacs -q and then start the server with M-x emacs-server and then try to edit a file with emacsclient <filename>, do you get the extra characters?
    – NickD
    Jun 15 at 3:37
  • Calling like that, emacs -q, throws some other errors but, opening with open -a Emacs --args -q, starting the server and then editing a file in the terminal do not inserts any other char!
    – Hugo
    Jun 15 at 17:31
  • 1
    Which probably means that the culprit is something in your init file. You will have to debug that and fix it. Probably the best way is to bisect your init file in order to zero in on the culprit.
    – NickD
    Jun 15 at 17:51

Following the advice from @NickD, I found the offending config on my init.el:

(global-set-key (kbd "M-[") 'insert-pair)
(global-set-key (kbd "M-{") 'insert-pair)
(global-set-key (kbd "M-\"") 'insert-pair)


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.