gvim mapping keys to ex commands while in visual mode?

0

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.

user2719875

Posted 2013-10-10T04:11:08.803

Reputation: 613

The most important part of your question is missing: your custom command. – romainl – 2013-10-10T04:48:57.270

Answers

1

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.

Ingo Karkat

Posted 2013-10-10T04:11:08.803

Reputation: 19 513