1

I want to use the i_CTRL-G mapping to abort the current cmp selection, but i_CTRL-G is already used by neovim.

I tried to delete the mapping with this:

vim.keymap.del('i', '<C-g>')

But it just said: E31: No such mapping


Any ideas how to do this? :)

5
  • Could you tell us what is the result of the following Vim command: :verbose imap <C-g>? Commented Apr 4 at 12:25
  • omg you are a vim god. Seems like my vim-surround plugin sets the keymap. Here the output: i <C-G>S <Plug>ISurround Last set from ~/.config/nvim/pack/plugins/start/vim-surround/plugin/surround.vim line 626
    – Bog
    Commented Apr 4 at 12:27
  • Thanks. The mapping you have is not on <C-g> but on <C-g>S. You have to delete that mapping explicitly. Commented Apr 4 at 12:33
  • 1
    I think you rather want to disable the mapping, instead of deleting it: let g:surround_no_insert_mappings=1, see github.com/tpope/vim-surround/blob/… Commented Apr 4 at 12:34
  • @ChristianBrabandt perfect addition. Write it as an answer so I can upvote it :)
    – Bog
    Commented Apr 4 at 12:39

2 Answers 2

1

There are no call that delete all the mapping that starts with a list of input. You have to delete all the mapping individually.

In your example you have to do:

vim.keymap.del('i', '<C-g>S')

Or:

vim.api.nvim_del_keymap('i', '<C-g>S')
6
  • 1
    Once again thank you really much for your help :))))
    – Bog
    Commented Apr 4 at 12:38
  • Thanks for the feedback :-) The solution to your particular problem is probably to follow the advise of @ChristianBrabandt :-) Commented Apr 4 at 12:40
  • Yeah I used @ChristianBrabandt's solution, but without you I would have never found the cause of the issue. I didn't know you can find all the mappings with the :verbose <mode> <keys> command :))
    – Bog
    Commented Apr 4 at 12:42
  • Also question to you: Should I rename / delete my question, since it is not what I though it would be? It feels kinda wrong^^
    – Bog
    Commented Apr 4 at 12:43
  • That would be nice. It increase the chance from other to find your question and the corresponding answers. Commented Apr 4 at 13:25
2

You can configure the vim-surround plugin to not create this insert mode mapping, by setting the following variable in your initialization script (assuming Vim here):

let g:surround_no_insert_mappings=1

Then you don't need to delete the mapping later on.

Taken from the plugin source

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.