I use ',' as leader, so when I f/t and I want to go to previous hit, I cannto use ','

I tried using #:

nnoremap # ,

My mapping shows up (I think), :map # shows this

n #      * ,

but it does nothing. Something obvious I am missing?


  • 1
    This should work just fine. Can you check that you can see the mapping with :map # (to query it?) Do you really have a next occurrence of the character you're searching in the same line, that , would normally find? – filbranden Aug 16 '19 at 23:16
  • 1
    added info, thanks! But while I was looking into this I realized what is most probably the issue. I am using vim-sneak, that takes over f with 'nmap f <Plug>Sneak_f'. I am pretty sure this has something to do..I should ask them maybe – Persimmonium Aug 17 '19 at 9:10
  • Please edit the question to mention vim-sneak... – filbranden Aug 17 '19 at 9:27

You mentioned vim-sneak in your comments, and that's probably it here.

vim-sneak will try to map ,. It actually expects you might be using , as a leader/localleader, it will check for whether you've mapped it and, if so, it will check for whether you've mapped \ to , and use that instead. You can see the code doing that here.

Since you want to use # instead, just map it directly to the <Plug> mapping exposed by vim-plug:

nmap # <Plug>Sneak_,
omap # <Plug>Sneak_,
xmap # <Plug>Sneak_,

It should be fine to add this to your vimrc (even though the plug-in actually gets loaded later on), but if you run into issues with that, consider creating a file named ~/.vim/after/plugin/*.vim and add those commands there instead, that will run after vim-sneak is loaded.

You could also use that file to remove any vim-sneak mappings from , (if it happens to be adding any), if you intend to use it as a leader.

| improve this answer | |

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.