In visual mode, how do I bind a key so that the selected text generates
; considering I never use it otherwise.
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.Sign up to join this community
xnoremap ; y<Esc>:%s/<C-R>"//g<Left><Left>
xnoremapvisual mode mapping, non-recursive
vnoremapincludes select mode as well, see What is the select mode and when is it relevant to use it?
;key to be mapped
yyank the selected text
<Esc>visual mode to normal mode
:%s/substitute command, all lines as range
<C-R>"paste contents of selected text
//grest of substitute command
<Left><Left>move cursor to the left twice