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.