I'm trying to use the insert-comment function provided by readline to uncomment a line.
According to the documentation:
If a numeric argument is supplied, this command acts as a toggle: if the characters at the beginning of the line do not match the value of comment-begin, the value is inserted, otherwise the characters in comment-begin are deleted from the beginning of the line
I have following line in my .inputrc for it:
"\eW": insert-comment 1
Which maps insert-comment to Alt-W (just for testing. I intend to remap Alt-# when it works)
On reloading .inputrc, entering some text on the terminal (like #123) and then pressing Alt-W, # gets prepended to whatever I type (like ##123), the same behaviour as Alt-#.
How do I use insert-comment function as a toggle mapped to a custom key sequence?