I have a custom "plugin" I use extensively for verilog development, and I have a few functions I obviously call using respective mapping.
For example:
function! FormatIoInstance() range
silent! :'<,'>v/\/\//normal! I.
silent! :'<,'>v/\/\//s/\s\+$//g
silent! :'<,'>v/\/\//s/,$/( ),/g
silent! :'<,'>v/\/\/\|,/normal! A( )
silent! :'<,'>v/\/\//Tab /(/l0
endfunction
with the following mapping for insert and select mode
inoremap <buffer> <silent> <nowait> <M-8> <C-o>:call FormatIoInstance()<CR>
snoremap <buffer> <silent> <nowait> <M-8> <C-o>:call FormatIoInstance()<CR>
However, extending the mapping to visual mode does not work (nothing happens) in visual mode:
xnoremap <buffer> <silent> <nowait> <M-8> <C-o>:call FormatIoInstance()<CR>
So what am I missing?
:help :v
: Instead of the '/' which surrounds the {pattern}, you can use any other single byte character, but not an alphabetic character, '\', '"', '|' or '!'. This is useful if you want to include a '/' in the search pattern or replacement string.