Hi, A.J.Mechelynck wrote: > > Kamaraju S Kusumanchi wrote: > > > > Let's say I open up a webpage, select some text and paste it into vim. Then > > all I see in vim is the text I see on the browser. While this is OK most of > > the times, sometimes I wish there is a way to paste the actual HTML code > > directly into the vim. > > > > Selecting "view source of the webpage" and then copy pasting into vim will > > work. But it is very cumbersome and time consuming. So this is not an > > option for me. > > > > Currently the editor in docs.google.com does what I need, Is there any way > > the same can be achieved by vim? > > Vim cannot get from the clipboard what isn't there: when you select text in a > browser (other than in View Source), what gets put onto the clipboard is the > text, not the source; IOW, the formatting tags aren't there.
actually, the selected HTML code might be available from the clipboard. E.g., both Firefox and Internet Explorer put it there in multiple formats. The following are lists of the available formats after copying from FF and IE, respectively: 49161: DataObject 49422: text/html 49366: HTML Format 49776: text/_moz_htmlcontext 49778: text/_moz_htmlinfo 13: CF_UNICODETEXT 1: CF_TEXT 49171: Ole Private Data 16: CF_LOCALE 7: CF_OEMTEXT 49161: DataObject 1: CF_TEXT 13: CF_UNICODETEXT 49366: HTML Format 49330: Rich Text Format 49171: Ole Private Data 16: CF_LOCALE 7: CF_OEMTEXT The formats starting with CF_ are pre-defined clipboard formats, the remaining ones are registered through Windows' RegisterClipboardFormat() function. I don't know how widely understood they are, but at least Microsoft Word is able to render headlines and other HTML-formatting instructions when text copied from Firefox is pasted into a document. It seems, the clipboard object associated with "HTML Format" contains enough information for correct rendering. A different point is how to access the HTML content in VIM. I doubt it would be a good idea to always paste the HTML source when accessing the clipboard through the + or * register. Probably a "pasteclipboard()" function which takes an argument for determining the preferred format would be a better way. This function function could then be used inside a mapping whenever a VIM user wants to paste the original HTML source. Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin)