Search code examples
vimkeyleader

Can I remap the "," command in VIM before using it as the leader key?


I like the way of working with "," as a leader key, but don't want to lose the original "," functionality, because it is very powerful with the "f" and "t" command.

Is there a way I can remap the original "," key, maybe invoking some internal low level VIM call?


Solution

  • Yes. By using :nnoremap, you can define a non-recursive mapping; i.e. the right-hand side isn't checked for mappings, so the original meaning of , is still accessible. For example, I remap ' for this (as the jump to mark functionality of ' is also and almost identically available with the ` command):

    :nnoremap ' ,