0

If I copy a selection from a webpage in Firefox or Chrome, I can paste into eg Thunderbird and retain formatting, links etc.

Is it possible to copy a selection of text with links etc in browser and paste into vim and retain the formatting/links etc?

I believe Notepad++ can do this.

4

The simple answer is no, it's not possible.

Vim is a text editor which handles text files:

  • It can't decide how to keep the formatting of e.g links: Is it supposed to past them as markdown [link](destination) as html <a> elements, etc...
  • It can't keep the font size when you can only have one font size in a buffer
  • It can't keep the colors and the font family when it must respect your colorscheme
  • and so on

So maybe if you have a precise idea of how you want to transform the text you paste to look the way you want in Vim you could use an autocommand to be executed each time something is put in the buffer from the external register and process the text with vimscript but that will be not trivial to do.

2
  • 2
    This is actually one of the things I use Vim for. I paste and then copy text to strip all formatting. – Davo Apr 22 at 16:24
  • I'm surprised that there's not some way to grab and process the additional information that's included when I copy text from a webpage or email client. I must admit, my only real interest is grabbing the URL behind textual links, and perhaps information regarding formatting. – Tom Apr 27 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.