I'm trying to use vim-repeat with a <Plug> that camel cases text:

nnoremap <silent> <Plug>CamelCase _ f_x~
\:call repeat#set("\<Plug>CamelCase")<CR>
nmap _ <Plug>CamelCase

This works fine for the most part, but in some cases it jumps to the beginning of the text and updates there:

function _noResponsesMessage(status_group) {

Even if I have my cursor at the beginning of status_group, it jumps to the beginning of the text and swaps there instead:

function NoResponsesMessage(status_group) {

Oddly, if I don't do this <Plug> setup and instead nmap it directly it works as expected:

nmap _ f_x~

Result as desired:

function _noResponsesMessage(statusGroup) {

Why does the first approach jump to the beginning of the line and the other replaces after the cursor?

1 Answer 1


If you look closely to your Plug:

nnoremap <silent> <Plug>CamelCase _ f_x~

You will notice that it consists of following normal mode commands:

  1. _ goto first non-blank char on the line
  2. goto next char
  3. and then your camelcase solution f_x~

Just remove it to match your nmap solution:

nnoremap <silent> <Plug>CamelCase f_x~
nmap _ <Plug>CamelCase

I would also suggest to name Plugs in using ():

nnoremap <silent> <Plug>(CamelCase) f_x~
nmap _ <Plug>(CamelCase)

or ;

nnoremap <silent> <Plug>CamelCase; f_x~
nmap _ <Plug>CamelCase;

Just to avoid plug name clashes.

Your Answer

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

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