1

I want to remap <C-x> in insert mode (I do not use the completion commands via this key). This is what I tried:

inoremap <C-x> <Esc> :x <Enter>
inoremap <C-x> <C-o> :x

Both variants are accepted by vim, but have no effect. When I execute :imap <C-x> I get:

<C-X> * <C-R>=<SNR>27_ManualCompletionEnter()<CR>.

I also tried to remove the default mapping:

iunmap <C-x>

which returns E474: Invalid argument.

So it seems that <C-x> is kind-of hard wired into vim and cannot be remapped. Is this correct or is there a way to achieve this?

1
  • 2
    Try :verbose imap <C-x>; I doubt that mapping is coming from Vim
    – D. Ben Knoble
    Aug 2 at 11:42

1 Answer 1

1

Your current <C-X> mapping is created by the Supertab plugin.

I'm not sure off the top of my head whether overwriting it will break that plugin, but you can test it out by setting up your mapping after Supertab has loaded.

One way to add this to your configuration is to use a VimEnter autocommand, which runs after the rest of the startup has completed. Add the following to your vimrc:

augroup MyCTRLX
  autocmd VimEnter * inoremap <c-x> <Esc>:x<Enter>
augroup END
3
  • Indeed! Last set from ~/.vim/pack/plugins/start/supertab/plugin/supertab.vim line 974 However, the autocommand doesn't change anything.
    – Tom
    Aug 2 at 16:41
  • Ok, I just commented out the mapping in supertab, I'm not using it anyway. Thanks a lot for the help!
    – Tom
    Aug 2 at 16:47
  • 1
    Correction: while commenting out that line makes c-x working, it destroys supertab, it doesn't work anymore w/o it. So, I'll find another key for the purpose.
    – Tom
    Aug 3 at 7:11

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.