Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.