0

I have defined the following mapping in my bootstrap-before function:

nnoremap <F5> <Space>jw

I was expecting that pressing F5 would trigger the jump-to-a-word command now. What happens instead, is that the default vim-mapping for the space key is activated instead of the SpaceVim-binding.

Things I have already tried:

  • Moving the binding to the bootstrap-after function
  • binding only the space key to F5
  • replace F5 with other keys
  • try to execute the command directly with :jump-to-a-word and :call jump-to-a-word() (Don't really know if these are even valid command/function names)

no success.

So my question is: Is there any way to know which commands correspond to the the bindings under the Space-prefix. So I can bind them to keys directly. Or can I add additional key bindings to the Space-prefix-commands in any other way than the bootstrap functions?

1

1 Answer 1

0

The SpaceVim bindings are actually mappings themselves, so in order to be able to use them in other mappings, you need those mappings to be recursive. In other words, you need nmap instead of nnoremap in this case.

nmap <F5> <Space>jw

Regarding the second part of the question:

Is there any way to know which commands correspond to the the bindings under the Space-prefix? So I can bind them to keys directly.

SpaceVim bindings are ultimately just mappings, so you can query those as you would regular mappings. Using :nmap <Space>jw will show you what the SpaceVim mapping for that key combination will do.

What you'll first see is:

n  <Space>       [SPC]

This is how SpaceVim implements its menu. But then :nmap [SPC]jw brings up the actual mapping:

n  [SPC]jw       <Plug>(easymotion-overwin-w)

So technically you should be able to use that setting for your alternative <F5> as well. Note that with this setting you also need a nmap instead of nnoremap, that's the case with all <Plug> mappings, which are built that way so you can change the key bindings you actually assign to them. So that's definitely a good option too.

4
  • Well, guess I could have at least thought of trying that. Thanks for the explaination. I'm fairly new to using vim regularly (apart from the occasional config file edit with the most basic commands). Works fine now. =D
    – 80KiloMett
    Nov 26, 2020 at 20:18
  • I just added more on how to find what's behind <Space>jw. I don't have SpaceVim installed, but by searching in the sources I believe that's what's behind it... So either mapping should work.
    – filbranden
    Nov 26, 2020 at 20:26
  • 1
    :nmap <Space>jw only brings up this: n <Space> [SPC]. But :nmap [SPC]jw brings up, what you described in your answer. Thanks for the command tip. =)
    – 80KiloMett
    Nov 26, 2020 at 20:35
  • @80KiloMett Thanks for the feedback! I updated the answer to reflect the actual mappings used by SpaceVim.
    – filbranden
    Nov 27, 2020 at 0:36

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.