0

I am using the following plugin to simplify tagging URLs in Markdown: tpope/vim-surround

This works:

nmap <leader>l <Plug>Ysurroundiw]%a(<C-R>*)<Esc>

This doesn't (notice the capital 'S'):

vmap <leader>l <Plug>YSurround]%a(<C-R>*)<Esc>

Any idea why?

Forethinker
  • 3,548
  • 4
  • 27
  • 48

2 Answers2

5

Surround is awesome but what about a more portable, plugin-agnostic, solution?

xnoremap <leader>l <Esc>`>a](<C-r>*)<C-o>`<[<Esc>
romainl
  • 186,200
  • 21
  • 280
  • 313
  • Just in case someone was wondering: this will create a markdown link for the selected text with the contents of the clipboard as url – aaronfc Feb 16 '22 at 11:11
4

Try using VSurround instead of YSurround since you're using a vmap.

Conner
  • 30,144
  • 8
  • 52
  • 73
  • So tricky. I kept typing `verbose vmap S` but still couldn't figure out why it was not working. I should watch out for similarity of V and Y in the future. – Forethinker Aug 12 '13 at 03:26