-
-
Save cstrahan/2368369 to your computer and use it in GitHub Desktop.
copy a vim buffer or selection as syntax-highlighted RTF to the clipboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" copy the entire buffer or selected text as RTF | |
" inspired by https://github.com/dharanasoft/rtf-highlight | |
" but only uses commands available by default on OS X. | |
" | |
" To set html conversion options, :help TOhtml | |
" And, undocumented, to set the font used, | |
" let g:html_font="Your Preferred Font" | |
" | |
function! CopyRTF(line1,line2) | |
if !executable('textutil') | |
echoerr "crap! textutil not found" | |
return | |
endif | |
call tohtml#Convert2HTML(a:line1, a:line2) | |
silent exe "%!textutil -convert rtf -stdin -stdout | pbcopy" | |
silent bd! | |
echomsg "RTF copied to clipboard" | |
endfunction | |
command! -range=% CopyRTF :call CopyRTF(<line1>,<line2>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What an amazing gist.