I use d/ a lot, so I decided to map / as follows:

:nnoremap <leader>j / (where <leader> is my space bar)

To my surprise, d<leader>j doesn't work. Why is that? I expect it to behave like d/.

I should add that <leader>j alone triggers the /, so it is indeed correctly mapped!


1 Answer 1


When you hit d, an operator, you enter Operator-pending mode. Vim will then wait for a motion command to be entered. In other words, when you follow d with <leader>j that's not happening in Normal mode...the mode for which you've mapped those keys.

For Operator-pending mode you need to use the :omap family of mapping commands, so...

:onoremap <leader>j /

Fortunately, there's a mapping type, :map, that encompasses both Operator-pending and Normal mode so you can kill two birds with one stone using

:noremap <leader>j /

However, this also includes Visual and Select modes so you need to be mindful of that. If that causes problems then just create two mappings (:omap and :nmap types).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.