0

I have the following line in my .inputrc which does not appear to be working:

"\C-/": insert-comment

When I press C-/ I expect the current line to be prefixed with the comment character (#) and executed, but when I press it nothing happens.

If I change the keymapping to something like \C-t then it works fine.

Why can't I use C-/ as a keymapping?

1 Answer 1

3

The readline library follows the model of a physical terminal that could only transmit ASCII control characters and ANSI escape sequences. C-/ is not an ASCII control character; the ASCII control characters are c-@, C-a .. C-z, C-[, C-\, C-], C-^, C-_.

4
  • So what does this mean for Meta sequences like M-#? Or are they not subject to the same restrictions? Commented Nov 3, 2017 at 7:49
  • Meta-# is by convention an escape control character followed by # (or whatever character you want to "metafy"). The Readline library can also be configured to interpret the eight bit, if set, as a meta flag if the terminal (emulator) supports this. But this is very esoteric, since it restricts the input character set to seven bits. Commented Nov 3, 2017 at 8:10
  • Are there limitations on which characters can be "metafied"? M-/ doesn't seem to work for me either. Commented Nov 3, 2017 at 9:11
  • For some reason I can't get the syntax "\M-/" to work in .inputrc either, but "\e/": "your action here" works. In my terminal emulator combining the Alt key with almost any key prepends an Esc to the key character. You can check by pressing Ctrl-v before the Alt-key combination, this prints the output like this: ^[/ (Alt-/ used as an example). Commented Nov 3, 2017 at 15:28

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.