What's it for?
To make sharing beautiful code as frictionless as possible.
Say you have a nicely syntax-highlighted buffer in vim. This plugin lets you open a browser tab with that buffer's contents, including the highlighting. If you copy-paste into a webmail window, a Google Doc, etc., the syntax highlighting stays intact.
Best of all, it cleans up after itself: it won't clutter your directories with
How do I install it?
Depends on your plugin manager.
Note that syncopate is a maktaba plugin, so you will need to install maktaba (if your plugin manager doesn't handle dependencies). If you want to configure the plugin, we strongly recommend installing glaive as well.
Here are instructions for Vundle, the most popular plugin manager.
Add the following lines between your
call vundle#begin() and
call vundle#end() lines.
" Dependency; required for vim-syncopate. Plugin google/vim-maktaba " Strongly recommended: easy configuration of maktaba plugins. Plugin google/vim-glaive Plugin google/vim-syncopate
Syncopate is expected to work on any platform vim supports, but the default configuration may not work on your system and direct-to-clipboard support hasn't been implemented for some platforms. Contributions welcome!
xclip to manipulate the clipboard. In most cases,
installing it from your package manager should just work.
Arch Linux's official repository has an
xclip (0.12.4) which is too old: it
--target. Arch users should install
xclip-svn from AUR:
yaourt -S xclip-svn
How do I use it?
Use the clipboard directly
It populates the clipboard with the contents of your buffer (or just part of it, if you're in visual mode), including highlighting.
You can then paste your beautiful code into a compose window (such as Gmail).
Of course, it's even better with a keymapping, which you can enable using Glaive:
" This line needs to go anywhere after 'call vundle#end()'. call glaive#Install() " Enable keymappings. Glaive syncopate plugin[mappings]
By default, syncopate's mappings all start with the prefix
You can change the prefix by giving
plugin[mappings] a value, like so:
Glaive syncopate plugin[mappings]='qwer'
The following examples will assume you're using the default prefix, and that your
:SyncopateExportToClipboardon whatever motion you choose. (e.g.,
,<ipwill copy the current paragraph (
ip) to the clipboard.)
:SyncopateExportToClipboardon the whole buffer (or your selection in visual mode).
Put it in a browser window
Alternatively, you can use the
It opens the HTML in a new browser tab, so you can select regions interactively.
Syncopate automatically cleans up the HTML file after opening the tab.
If you use
:SyncopateExportToBrowser, be sure to copy with
Ctrl-C (as opposed to mouse selection/middle-click); otherwise, the highlighting will not be retained.
How do I configure it?
There are a variety of syncopate-specific options: whether to change the colorscheme, which browser to use, etc.
For everything else, use the built-in options for the
(Options are down below, starting at
For example, the following line will exclude line numbers from the output, even if you use them in vim:
let g:html_number_lines = 0
So how's this different from plain :TOhtml?
Under the hood,
- Switch to the default
colorscheme(it shows up better on white backgrounds).
- Create the HTML version of your vim buffer.
- Export it to the clipboard.
- Restore your
colorscheme, and any other settings it needed to change.
:TOhtml only does the second step.
In particular, the third step is difficult to remember how to do.
:TOhtml usually involves tiresome saving-and-subsequently-deleting of HTML files, and fiddling with a browser.