I was trying to make a mapping to run a command that takes a count, something like the following:

nnoremap gb :execute('buffer ' . v:count)<CR>

When I run the mapping, I see the following error:

E481, No range allowed

After checking this post, I find it is because vim will insert a range automatically if we press a number before pressing colon : to enter command line.

Is there documentation on this behavior? Can I disable it by default?

1 Answer 1


I’m not sure about documentation, but this can be useful to say 5:normal! Somecommands, or some such (I don’t use it often, but I can imagine a situation in which it’s easier than typing the corresponding range myself).

As for disabling it, use the old visual-mapping trick:

nnoremap gb :<C-u>...
  • I am still learning to write vim script. The vim error in this case is hard to figure out, IMO. The Ctrl-U trick is neat and solves the problem.
    – jdhao
    Commented Oct 16, 2020 at 13:42

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.