While writing this answer about vim-rails on SpaceVim, I found out these mappings set by SpaceVim, such as this one:

nnoremap gf gf

SpaceVim also creates similar mappings for all of the other gX commands and all zX commands as well.

Which made me wonder: Why would you need such mappings?

As far as I can tell, they don't actually do anything. They just map a key sequence to itself, so they'll simply have Vim execute the exact same command as if the mappings were not there. (Or am I wrong about that and there's a subtle difference when such a trivial mapping is actually installed?)

I suspect they have something to do with the leader guide for the g (and z) commands, but I still don't understand why they're needed.

Can someone familiar with SpaceVim (implementation) or with this particular code pattern please clarify?


I think I can make a guess (but I have never seen this before either, and I haven't used SpaceVim yet) based on this issue: gq for reformatting doesn't work #787. nmap g [G] essentially blocks all the usual normal-mode commands that start g. gq, for example, is now [G]q.

nnoremap gf gf, by virtue of being a noremap version, blocks further mapping expansion, so gf effectively remains a plain gf.


I am author of SpaceVim. The main feature of spacevim is key binding guide. This feature need to run :map <prefix> to paser all mappings, and generate guide context. In vim, too many default key binding begin with g, most users include me do not remenber all of them. so I need the guide when I forgot next key after press g.

enter image description here

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.