├── MIT-LICENSE ├── README.md └── plugin └── rtf_pygmentize.vim /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Rafael França 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vim RTF Pygmentize 2 | 3 | Suppose you will write a presentation using Keynote and need to convert chunks of code to Keynote without losing 4 | syntax highlighting. This plugin helps you with that: it converts pieces of code to RTF and copies it to 5 | the OSX clipboard. 6 | 7 | It is basically a wrapper around the [pygments](http://pygments.org/) library, and was created to 8 | help me adding chunks of code to my Keynote presentations. 9 | 10 | ## Dependencies 11 | 12 | Right now this plugin only works on OS X, but I would be grateful if someone make it work in 13 | another systems. 14 | 15 | Before installing the plugin, you need to install the pygments library. You can do it with the following command: 16 | 17 | ``` 18 | easy_install pygments 19 | ``` 20 | 21 | ## Configuration 22 | 23 | There are two available options to configure this plugin: 24 | 25 | ```vim 26 | " Valid options are: 'default', 'emacs', 'friendly' and 'colorful' 27 | let g:rtfp_theme = 'emacs' 28 | ``` 29 | 30 | You can use the [vim2pygments](https://github.com/honza/vim2pygments) project to generate more themes to pygments using your vim themes. 31 | 32 | and 33 | 34 | ```vim 35 | let g:rtfp_font = 'Monaco' 36 | ``` 37 | 38 | ## Usage 39 | 40 | To highlight a file, you can use: 41 | 42 | ```vim 43 | :RTFPygmentize 44 | ``` 45 | 46 | You can also specify the language to use on highlight with: 47 | 48 | ```vim 49 | :RTFPygmentize 50 | ``` 51 | 52 | It also works with visual selections. 53 | 54 | ## Inspiration 55 | 56 | This Vim plugin is inspired at [rtf-highlight](https://github.com/dharanasoft/rtf-highlight) plugin 57 | 58 | ## Maintainers 59 | 60 | Rafael Mendonça França (https://github.com/rafaelfranca) 61 | 62 | ## License 63 | 64 | MIT License. Copyright 2011 Rafael França 65 | -------------------------------------------------------------------------------- /plugin/rtf_pygmentize.vim: -------------------------------------------------------------------------------- 1 | " rtf_pygmentize.vim 2 | " Rafael França 3 | " 4 | " License 5 | " This program is under a MIT License 6 | 7 | " syntax theme 8 | " Valid options are: 'default', 'emacs', 'friendly' and 'colorful' 9 | if !exists('g:rtfp_theme') 10 | let g:rtfp_theme = 'default' 11 | end 12 | 13 | " Text font 14 | if !exists('g:rtfp_font') 15 | let g:rtfp_font = 'Menlo' 16 | end 17 | 18 | function! RTFPygmentize(line1,line2,...) 19 | if !executable('pygmentize') 20 | echoerr "Bummer! pygments not found." 21 | return 22 | endif 23 | 24 | let ft = a:0 ? a:1 : &filetype 25 | 26 | if ft == "eruby" 27 | let ft = "rhtml" 28 | endif 29 | 30 | let content = join(getline(a:line1,a:line2),"\n") 31 | let command = "pygmentize -l " . ft . " -f rtf -O style=" . g:rtfp_theme . ",fontface=" . g:rtfp_font . " 2> /dev/null" 32 | let output = system(command,content) 33 | let retval = system("pbcopy",output) 34 | endfunction 35 | 36 | command! -nargs=? -range=% RTFPygmentize :call RTFPygmentize(,,) 37 | --------------------------------------------------------------------------------