6

I was manually creating a table in my source code's multiline comments and inserting horizontal separators using - and =. E.g. C-u C-u C-u = as expected and inserts 64 =s at the point. But - is used to provide negative arguments and does not work in the same way. describe-function for universal-argument does not address this.

So, is there a way of interpreting - as a "raw character" instead of part of a key chord?

5
  • 1
    While it does not work using C-u, it does work using the C-0 to C-9 characters, for 64 minus signs you can use C-6 C-4 - (Meta and Control can both be used together with digits to specify the universal argument.)
    – rsp
    Commented Apr 25, 2023 at 10:02
  • 2
    The C-q mechanism described in @shynur's answer is completely general and useful in many places: it's worth remembering. And because of that, I suspect that this is a duplicate question, but I haven't done a search to confirm yet.
    – NickD
    Commented Apr 25, 2023 at 12:12
  • After seeing @shynur's answer, I tried searching for "quoted insert", but nothing relevant came up.
    – loonatick
    Commented Apr 25, 2023 at 13:36
  • 2
    @NickD : here the by you suggested existing duplicate: emacs.stackexchange.com/questions/7135/…
    – oOosys
    Commented Apr 26, 2023 at 14:29
  • Unfortunately, it does not mention C-q, and the C-u method will not work e.g. with C-u C-u -: the C-u does not quote the -. So it doesn't quite qualify as a duplicate in my book, but thanks for finding it. To some extent, all of these are corner cases, but they do tent to trip people up. Gilles' answer below is the most comprehensive one I have seen.
    – NickD
    Commented Apr 26, 2023 at 14:54

2 Answers 2

9

For example, C-u C-u C-q -.

You can C-h k C-q for more details.

4

To type a minus sign with a numeric prefix argument, you can enter the number by typing the digits: C-u 6 4 - or ESC 6 4 - or M-6 M-4 - or C-6 C-4 - (or a few other combinations). This method doesn't let you abbreviate 4n by typing C-u n times.

Another method, which also works with a digit, is to use the C-u prefix, then enter the number, then another C-u and finally the character. For example C-u 6 4 C-u - inserts 64 minus signs, and C-u 6 4 C-u 0 inserts 64 zeros. This method doesn't let you abbreviate 4n by typing C-u n times.

In most cases, an alternative way is to use C-q before the minus sign, e.g. C-u C-u C-u C-q - inserts 64 minus signs. However there are a few cases where this is different, such as Overwrite mode, where C-q inserts instead of overwriting. This method doesn't work for digits (except 8 and 9 when read-quoted-char-radix is the default octal): you would have to type the digit's octal code (or dec/hex if you've changed the radix), e.g. C-u C-u C-q 6 0 RET to insert 0000000000000000.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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