1

I've tried :help i_CTRL-G_CTRL-G and :helpgrep CTRL-G more generally and can't figure out why <c-g><c-g> is equivalent to a <nop> in insert mode.

For some context, I was having problems with the mapping:

nnoremap ` <nop>

And it was suggested in a comment here: Using a no-op key in insert mode, can't use key after using no-op mapping That I should use

nnoremap ` <c-g><c-g>

instead.

Using this workaround the problem is avoided, but I can't figure out why it works. In particular, I'm trying to understand how <c-g><c-g> duplicates some or perhaps all of the observable behavior of <nop> ... while simultaneously hitting a different enough codepath to avoid triggering the bug.

3

As you saw in your search :help i_CTRL-G_CTRL-G doesn't exist. It simply means that by default it is mapped to nothing thus pressing CTRL-GCTRL-G will do nothing which is equivalent to <nop>.

In their comment @Mass said it is a workaround: you are abusing the fact that CTRL-GCTRL-G does nothing to replicate the behavior of <nop> without sending the <nop> keycode. You could get the equivalent with basically any nonexisting mapping like <c-g><c-a>, <c-g><c-b>, etc

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.