Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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 +le.pl
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.

-Nathan


Comment on Re: Using vim for highlighting in Perl
Select or Download Code
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" foo.pl
    Note that it produces the output in foo.pl.html, 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2014-10-24 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (131 votes), past polls