Search code examples
vimmappingneovim

neovim remapping . to ;


I have remapped quite a few things so far in Neovim. I like to use f with , and ; to navigate to a specific character. But, I am trying to experiment with ; being a leader key and I wanted . to take its place. This will allow me to use f with , and . to navigate to the desired character. But, noremap . ; doesn't change the behavior of .. , and ; continue to work with f instead of , and ..

I expected to be able to use f and , to navigate backwards and f and . to navigate forwards.

,.; continue to behave normally despite this being in my init.vim file


Solution

  • noremap???? Since you said you have remapped quite a few things in Neovim. I assume that was a typo and what you actually meant was nnoremap there.

    You must know the dangers of mapping . to ; first, which will make the normal behaviour of . to be lost (i.e. you will not be able to use the "repeat the last command with .") unless you map something else to . as well.

    First step to your problem would be mapping with . to ;, which means whenever you type . in normal mode, it will behave as if you had actually typed ;(functionality of ; command in normal mode will be copied to . character) :-

    nnoremap . ;

    (This works for me, I use Neovim as well, It HAS to be the typo.)

    , and ; continue to work with f instead of , and .

    At this point, . should be able to use . as ;, but since you haven't mapped ; to anything at this point, ; will functoin as before. Now, The second step would be mapping ; as leader key. Which will make ; lose its normal functionality, and you will not be able to use ; to jump to the next search character.

    let mapleader = ";"

    Put the code above in your init.vim to make ; you leader key.