1

I have a map that creates a markdown hyperlink for the current url open in the browser:

inoremap <Leader>gg [<esc>:silent !~/bin/copy_safari_title.osa <cr>"+pa](<esc>:silent !~/bin/copy_safari_url.osa <cr>"+pa)

This works fine. Now I want to remove any instances of the pipe character from the link description. So I modified the above command:

inoremap <Leader>gg [<esc>:silent !~/bin/copy_safari_title.osa <cr>:let "+ = substitute("+, '\|', '', 'g')<cr>"+pa](<esc>:silent !~/bin/copy_safari_url.osa <cr>"+pa)

Note the :let "+ = substitute("+, '\|', '', 'g')<cr> in this newer command.

But it ends up echoing what looks like all the vim variables to the screen and though there is output to vim, any pipe character is still in the description. Not sure what is happening. What am I missing?

1

OK, got it. Was using wrong sigil. Instead of "+ you need @+. So:

inoremap <Leader>gg [<esc>:silent !~/bin/copy_safari_title.osa <cr>:let @+ = substitute(@+, '\|', '', 'g')<cr>"+pa](<esc>:silent !~/bin/copy_safari_url.osa <cr>"+pa)

1
  • 1
    Yeah, the map command sees " as the end (comment start), and so you end up executing :let. I’d just put it in a function at this point.
    – D. Ben Knoble
    Jul 15 '20 at 2:28

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.