Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Using vim for highlighting in Perl

by ndwg (Beadle)
on Mar 26, 2003 at 17:15 UTC ( #246000=note: print w/replies, xml ) Need Help??

in reply to Using vim for highlighting in Perl

Great idea. I could see how this could be a nice feature to add to some of my projects, so I did a little research and here is what I came up with:

The relevant reading in vim...

:help syntax :help 2html

From the command line...

vim -f +"syn on" +"so \$VIMRUNTIME/syntax/2html.vim" +"wq" +"q" yourfi
This will create yourfile.html in the current directory. I had to tweak the resulting HTML to change the background from white to black. (Perhaps since that is what my terminal background color is, that is the colors that vim used.) I would be very interested to know if you come up with any improvements on this method.


Replies are listed 'Best First'.
Re: Re: Using vim for highlighting in Perl
by Hrunting (Pilgrim) on Mar 26, 2003 at 19:43 UTC
    This is pretty close to what I'm looking for. The 2html.vim syntax is pretty easy to figure out, so customizing it to produce the kind of output I desire shouldn't be too difficult. Large files take a good deal of time to colorize, but that's the case in normal vim. The only downsides I can see to this method are that it requires an extra file to be created (it's running in a separate vim window) and it's pretty heavy on the old resources. Wrapping it in a module shouldn't be too difficult, though.
Re^2: Using vim for highlighting in Perl
by Aristotle (Chancellor) on Mar 30, 2003 at 20:07 UTC
    To make the generated markup c?leaner, as well as much easier to recoulorize, set the html_use_css variable.
    vim -f +'syntax on | let html_use_css = 1 | source $VIMRUNTIME/syntax/ +2html.vim | write | qall"
    Note that it produces the output in, not foo.html. You could also replace the write with a saveas /tmp/foo to have the result always placed in /tmp/foo which may be more convenient for shell scripting.

    Makeshifts last the longest.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://246000]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2020-10-25 17:03 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (249 votes). Check out past polls.