开发者

Any way to copy a syntax-coloured file in Vim as HTML?

I've got a couple of files loaded in V开发者_如何学Pythonim, but I wanted to post the contents with the colouring that Vim is providing. Short of print-screen, is there a way to do this? Ideal would be a copy/paste as HTML, but I suspect I'm going to be disappointed.


You just need to enter the command

:TOhtml


Alongside with built-in :TOhtml which was already mentioned, you can try my plugin which is more customizable: format.vim. Its advantages over 2html are explained on the plugin page.


I put together a solution that I'm pretty happy with recently for copying rich text to paste into my mail client. Replace the app specifics as appropriate for your setup.

" open the selection in Internet Explorer so it can be copied as rich text
function! OpenInIE() range
    execute a:firstline . "," . a:lastline . 'TOhtml'
    silent !start "C:\Program Files (x86)\Internet Explorer\iexplore.exe" %:p
    sleep 2
    silent !del %:p
    q!
endfunction

and

noremap <F7> :call OpenInIE()<CR>

Once the IE window opens, I hit Ctrl-A followed by Ctrl-C and then I have the rich text in the clipboard.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜