3

Is it expected that C-M-% and ESC C-% do not run the command query-replace-regexp when running emacs in a terminal window (for example, emacs -nw)?

According to describe-function the binding exists, but emacs runs query-replace instead (which has the binding M-%). This has happened on several machines I've tried it on, and does not happen when I run emacs in a window.

jonderry
  • 23,013
  • 32
  • 104
  • 171

3 Answers3

3

The problem is that C-% simply can't be typed in a terminal. The only control sequences available are those that corresponds to ascii-code 0-31, mainly C-letter.

Lindydancer
  • 25,428
  • 4
  • 49
  • 68
  • 2
    More details here: http://serverfault.com/questions/190351/control-punctuation-doesnt-register-in-terminal/190366 but it should also be dependent on the abilities of the terminal being used: http://stackoverflow.com/questions/4337837/send-c-to-emacs-in-vt100-xterm-terminal-mac-os-xs-terminal – phils Sep 24 '11 at 03:27
1

I have created a new shortcut in my .emacs file.

(global-set-key "\M-q" 'query-replace-regexp)

downeyt
  • 131
  • 1
  • 3
1

Control-Alt-Shift-% all together works on Windows and Fedora Linux. Does your keyboard have all those keys?

Howard Rubin
  • 350
  • 2
  • 14
  • It does work for me in mintty in WIndows, but does not work in Gnome Terminal. When you say it works in Fedora Linux, are you talking about Emacs in its own window or Emacs running within a terminal (e.g. "emacs -nw")? If you are talking about terminal Emacs, what Linux terminal are you using? – paulie4 Jun 27 '16 at 00:43
  • Works for me on Windows 10 (Emacs 25.3.1). – Abbas Jul 28 '18 at 22:09