1

Because the keys d and xare used in normal mode to delete letters, I map <ctrl-d> and <ctrl-x> in insert mode to delete and backspace.

However, when I started to use completion plugin (I use supertab now, though it doesn't update recently, it still works good), if I press <ctrl-x> in insert mode, vim jump into CTRL-X mode.

After searching, I found that key <ctrl-x> actually predefined in ins-completion feature. Because using supertab I can use <tab> to search completion, I still want to use <ctrl-x> as backspace in insert mode. Is there a way to do that?

1

It sounds as though the supertab plugin has either overwritten or removed your insert mode mapping. You can check if this is the case with the command:

:verbose imap <C-X>

You can reinstate your mapping simply by re-running your map command again:

:inoremap <C-X> <BS>

The best way to do this automatically in your vim configuration is probably to use the after directory as suggested by @filbranden in the comments:

Create a .vim file with any name in the location:

~/.vim/after/plugin/

with the contents:

inoremap <C-X> <BS>

This will be run after supertab (and all other plugins) and so can override its settings. See :help after-directory for more details.

  • I execute :verbose imap <C-X>, it says Last set from .......supertab\plugin\supertab.vim – Shan-Hung Hsu Sep 2 at 13:34
  • I guess I can add autocmd to remap <ctrl-x> when I enter insert mode – Shan-Hung Hsu Sep 2 at 13:36
  • I add command autocmd InsertEnter * inoremap <C-x> <BS> in my .vimrc, and works, thank you – Shan-Hung Hsu Sep 2 at 13:47
  • The best way to override settings from plug-ins is in files under ~/.vim/after, which are run after plug-ins load. In this case, putting inoremap <C-x> <bs> in ~/.vim/after/plugin/ctrl-x.vim (or any other file *.vim in that directory) would solve that. – filbranden Sep 2 at 17:55
  • 1
    @filbranden Huh. For some reason I had it in my head when I wrote this answer that some plugin managers actually load plugins with :runtime rather than just manipulating the 'rtp', in which case it would be arguably simpler just to move the setting further down in your vimrc. I can't find any evidence that this is true now, though. I'll update my answer to include your suggestion. – Rich Sep 3 at 9:44

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.