AddPutting aside mappings for a moment, what do we do when we're manually entering commands and find a range on the command line that we don't want? Hit Backspace five times? Well...yes...that's one possibility but there's something better than that:
c_CTRL-U
CTRL-U Remove all characters between the cursor position and
the beginning of the line. ...
Since a mapping is essentially the same as the equivalent manual command we just need to translate Ctrl+U to something that works in Vimscript. That would be the equivalent keycode <C-U>
to.
So add <C-U>
at the beginning of your mapping right after the opening :
. For example:
vnoremap XX,a :<C-U>silent! ..etc..
ThisThat will clear whatever mayany text that happens to currently be on the command line.
See :h c_CTRL-U
before your command(s) are applied.