Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there some program that can parse vim syntax highlighting scripts and colorize code for export to the shell? Basically I am looking for cat/less with shell highlighting that draws its syntax from vimscript definitions, so I can define my own.

addendum: A preferred solution would be a program that outputted to stdout directly, like cat, so i could pipe to less or whatever i would want to use it for

share|improve this question
    
I've never heard of something like that. But did you try {pygments](pygments.org)? –  romainl Feb 19 '13 at 6:13
    
@romainl I did look at pygments, but there is support for customization in the matter I am looking for –  Justin L. Feb 19 '13 at 19:01

2 Answers 2

For use as a pager, Vim comes with $VIMRUNTIME/macros/less.sh. See here on the Vim Tips Wiki. There's also a plugin alternative, vimpager, and you'll probably find more on the Web.

share|improve this answer
    
This is nice and I will probably be using it :) However it might be nice to have something that prints directly to stdout. –  Justin L. Feb 19 '13 at 19:07

I answered a similar question on StackOverflow:

Matthew Wozniski wrote a script called vimcat.sh that does this with Vim. His version is at https://github.com/godlygeek/vim-files/blob/master/macros/vimcat.sh. I've made a few modifications to it (if memory serves, the modifications allowed it to run on my Mac OS X system; I know the substitution of /dev/fd/9 for /proc/self/fd/9 had that purpose); see my gist at https://gist.github.com/4090959.

I believe both versions of the script have trouble with returning to default background color if Vim's highlighting changes the background.

share|improve this answer
    
Thank you for this, this is almost exactly what I was looking for :) Do you know if it's possible to have this work with stdin? –  Justin L. Feb 19 '13 at 23:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.