0

I am trying to remap this functionality: enter image description here to Ctrl+Space, by using this line in .vimrc

inoremap <C-Space> <C-n>

However, I can not seem to get it to work. If I press Ctrl+Space after starting up, I get this error:

E29: No inserted text yet

Which I suppose is already mapped to a clipboard which tracks your last input. I would rather swap the functionality as auto-complete is more important to me. What am I doing wrong?

  • Please clarify what you mean by "Autocomplete". – klaus Oct 9 at 8:01
  • If it's native :h ins-completion you're talking about, then you should be good to go with inoremap <C-space> <C-n> – klaus Oct 9 at 8:01
  • @klaus For what its worth, I was going to send a screenshot, but it stopped working so... Basically its when it gives you a box of options and keywords you can cycle through. – Akiva Oct 9 at 8:30
2

Your terminal send ^@ as <c-space> to vim, ^@ is ctrl-@, it's equivalent to <Nul> in vim, check :h keycodes if you have doubts.

You get E29: No inserted text yet error message because :h i_CTRL-@ is trying to insert previously inserted text (it doesn't exist).

To fix it, use:

inoremap <Nul> <c-n>

or

inoremap <c-@> <c-n>

or

map <Nul> <c-space>
map! <Nul> <c-space>
inoremap <c-space> <c-n>

Personally i think you should get used to <c-n>, it's one of the most useful shortcut key in vim.

2

I believe you’ve got the map syntax backwards (see :help :map): try

inoremap <C-Space> <C-n>

Also see :help ins-completion

  • You were right, I had it backwards, however the remap still has not worked. I updated the question; thanks for fixing that. – Akiva Oct 10 at 4:29

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.