sponsor Vim development Vim logo Vim Book Ad

publish.vim : Publish hyperlinked, highlighted source code using Vim, 2html.vim and rsync

 script karma  Rating 17/5, Downloaded by 2574    Comments, bugs, improvements  Vim wiki

created by
Peter Odding
script type
This plug-in uses the 2html.vim script included with Vim's runtime files to publish a collection of syntax highlighted files as HTML documents and then replaces identifiers such as function and variable names in the HTML output with hyper links (based on available tags as generated by Exuberant Ctags). The result is a directory (tree) of syntax highlighted, interlinked HTML documents. I've published the plug-in's source code as a demonstration at http://peterodding.com/code/vim/profile/plugin/publish.vim. For more information about the plug-in please refer to its homepage or the project page on GitHub:


If you have questions, bug reports, suggestions, etc. the author can be contacted at peter@peterodding.com. If you like this plug-in please vote for it below!
install details
Unzip the most recent ZIP archive file (see below) inside your Vim profile directory (usually this is "~/.vim" on UNIX and "%USERPROFILE%\vimfiles" on Windows), restart Vim and execute the command ":helptags ~/.vim/doc" (use ":helptags ~\vimfiles\doc" instead on Windows).

As an example we'll publish the plug-in using itself. First create a tags file that contains entries for the files you want to publish using a shell command such as:

    ctags -Rf ~/.publish_tags ~/.vim/

If this doesn't work because "ctags" isn't installed you can download it from the Exuberant Ctags homepage http://ctags.sourceforge.net/ or if you're running Debian/Ubuntu you can install it by executing the following shell command:

    sudo apt-get install exuberant-ctags

The plug-in needs an up-to-date tags file so that it can create hyper links between the published files. Now start Vim and write a script that registers the tags file you just created and calls the function Publish() as follows:

    set tags=~/.publish_tags
    let sources = '/home/peter/.vim'
    let target = 'sftp://peterodding.com/code/vim/profile'
    call Publish(sources, target, [
        \ 'autoload/xolox/escape.vim',
        \ 'autoload/xolox/path.vim',
        \ 'autoload/publish.vim',
        \ 'plugin/publish.vim',
        \ ])

Change the "sources" and "target" variables to reflect your situation, save the script as "~/publish_test.vim" and execute it in Vim by typing ":source ~/publish_test.vim" (without the quotes) and pressing Enter↵. If everything goes well Vim will be busy for a moment and after that you will find a bunch of syntax highlighted, interlinked HTML documents in the target directory!

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
publish.zip 1.7.14 2013-08-19 7.0 Peter Odding Remove compatibility checking of miscellaneous scripts:

Cleaned up old miscellaneous scripts:

Document vim-misc as external dependency:

Make sure vim-misc is installed, politely complain if it isn't:
publish.zip 1.7.13 2013-05-20 7.0 Peter Odding Updated miscellaneous scripts:
publish.zip 1.7.12 2013-05-19 7.0 Peter Odding Updated miscellaneous scripts:
publish.zip 1.7.11 2013-05-13 7.0 Peter Odding Updated miscellaneous scripts:
publish.zip 1.7.10 2013-05-02 7.0 Peter Odding Updated miscellaneous scripts:
publish.zip 1.7.9 2013-04-28 7.0 Peter Odding Updated miscellaneous scripts:
publish.zip 1.7.8 2013-04-21 7.0 Peter Odding Make compatibility with miscellaneous scripts explicit:
publish.zip 1.7.7 2011-11-26 7.0 Peter Odding Updated miscellaneous scripts:
publish.zip 1.7.6 2011-11-21 7.0 Peter Odding Updated miscellaneous scripts:
publish.zip 1.7.5 2011-09-25 7.0 Peter Odding Updated miscellaneous scripts:
publish.zip 1.7.4 2011-09-04 7.0 Peter Odding Move version variable to autoload script, include in every message:

Updated miscellaneous scripts
publish.zip 1.7.1 2010-09-05 7.0 Peter Odding Bug fix: Avoid Vim's hit-enter prompt:

Instrumented plug-in with xolox#timer#* calls:

Proper HTML encoding, foolproof publish#customize_html():

Bug fix: Make 2html ignore text folding:

Bug fix: Proper escaping in pattern_to_lnum():

Bug fix: Proper escaping in create_subst_cmd() to avoid E33:

Bug fix for publish#html_encode():

Simplified tags -> hyperlinks conversion hack:

Smarter integration with easytags.vim:

Fixed easytags#update() to overcome argument limit:
publish.zip 1.6 2010-06-15 7.0 Peter Odding * Bug fix for :doautocmd User PublishPre hook:

* Bug fix: Escape ~ in tag search patterns:

* Improved handling of VimL script-local functions:

* Always prefer earlier tag definitions in the same document:

* Faster remote publishing using rsync (automatically enabled):
publish.zip 1.5.2 2010-06-06 7.0 Peter Odding Now includes generated Vim documentation based on README
publish.zip 1.5.1 2010-06-05 7.0 Peter Odding Bug fix: Fixed usage instructions to include tags generation :-\
publish.zip 1.5 2010-06-05 7.0 Peter Odding Completely switched directions by forgetting about incremental, automatic publishing (which interferes with the user because "2html.vim" is too slow) and instead focusing on batch publishing of multiple related files, which means the plug-in can now include hyperlinks between the published files based on tags.
publish.vim 1.0 2008-05-25 7.0 Peter Odding Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo