In visual mode, how do I bind a key so that the selected text generates


? Preferably ; considering I never use it otherwise.


xnoremap ; y<Esc>:%s/<C-R>"//g<Left><Left>
  • xnoremap visual mode mapping, non-recursive
  • ; key to be mapped
  • y yank the selected text
  • <Esc> visual mode to normal mode
  • :%s/ substitute command, all lines as range
  • <C-R>" paste contents of selected text
  • //g rest of substitute command
  • <Left><Left> move cursor to the left twice
  • 3
    better to use xnoremap – Christian Brabandt Aug 7 '18 at 5:35
  • 1
    @ChristianBrabandt done, searched about differences and added a link to select mode... – Sundeep Aug 7 '18 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.