Forethinker
Forethinker

Reputation: 3758

Mapping Surround.vim plugin to add Markdown link in visual mode

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?

Upvotes: 0

Views: 294

Answers (2)

romainl
romainl

Reputation: 196476

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

xnoremap <leader>l <Esc>`>a](<C-r>*)<C-o>`<[<Esc>

Upvotes: 5

Conner
Conner

Reputation: 31040

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

Upvotes: 4

Related Questions