Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So in gvim, after I press

<Shift> + v

it goes into visual mode. I normally have an ex command set for the letting 'm'. When I go into visual mode and then hit 'm' it says

No range allowed

How do I make it so that when I push 'm' in visual mode, it does

:ya +

Basically, I want it so that after I highlight something in visual mode, if I click 'm', it copies it to my clipboard so that I can paste it on stuff outside of gvim.

share|improve this question
The most important part of your question is missing: your custom command. – romainl Oct 10 '13 at 4:48
up vote 1 down vote accepted

That (yanking to clipboard) would be a simple

xnoremap m :ya +<CR>

Without your mapping, I can't say where that No range allowed comes from. The :, when pressed in visual mode, automatically inserts the :'<,'> visual range, and the :yank command takes a range, so all works out well. On the other hand, should you have a command that doesn't take a range you'd have to clear it via :<C-u>command ....

Note: I used :xmap instead of :vmap because in select mode, printable letters should replace the selection, not invoke a mapping.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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