in reply to Re: Comments in my code
in thread Comments in my code

Here is an example of gvim's syntax highlighting capabilities for the curious:

#!/usr/bin/perl -w
#####################################################
# Script:   mp3_average_year
# Author:   Jeff Anderson
# Date:     03/15/2001
# Comments: finds average year of my mp3 collection
#####################################################

use strict;
use File::Find;
use MP3::Info;

my ($sum,$count);
my $start = shift || '/mnt/lump/mp3';

find sub {
    if (/mp3$/) {
        my $tag  = get_mp3tag($_);
        my $year = $tag->{'YEAR'};
        next unless $year =~ /^\d+$/;
        next unless ($year > 1950 and $year < 2002);
        $sum += $year;
        $count++;
    }
}, $start;

print "$sum / $count = " . $sum / $count . "\n";

UPDATE:
Oh yeah, _PLEASE_ don't actually do what i just did and actually post gvim rendered HTML, as the resulting HTML increases in size tenfold. Guess that makes me a hypnotist.

jeffa

i liked it better than cats, i will use gvim again and again ...

  • Comment on (jeffa) 2Re: Comments in my code (gvim syntax highlighting example)

Replies are listed 'Best First'.
Re:x3 Comments in my code (gvim syntax highlighting example)
by grinder (Bishop) on Nov 13, 2001 at 14:26 UTC
    <rant>

    Looking at that reminds me why I hate syntax-colouring editors. And I am indebted to stefp for jogging my memory, by talking about angry fruit salad (on the Paris Perl Mongers list -- this subject came up the other day).

    I know, I know, the colours can be configured, but I still why wonder why a person with a knowledge of psycho-optics and some decent design skills hasn't come up with a default that's useable in the first place. Edward Tufte springs to mind.

    I finally managed to wean my self off Notepad, and use vim in Windows... after having figured out how to turn syntax coloring... off.

    </rant>
    --
    g r i n d e r
      Beauty is indeed in the eye of the beholder, and i must admit that the color scheme i demonstrated pleases my eyes quite well. But, i totally understand where you are coming from, and your link to the Edward Tufte site has inspired me:
      
      #!/usr/bin/perl -w
      
      use strict;
      use constant FOO => 'bar';
      
      my @array = qw(one two three);
      my $scalar = 'when in Rome';
       # some comments
      print "i like Rome\n" if $scalar =~ /Rome/;
      print "no digits\n"   if $scalar !~ /\d+/;
      
      sub foo {
          return 'foo';
      }
      
      
      Needs some more tweaking, but you get the point - if it's the colors themselves that bother, and not the notion of syntax highlighting, then just change them to suite your needs. Here is the pertinant .gvimrc config info:
      hi Normal guifg=#35351d guibg=#fffff3 hi PreProc guifg=#de022a guibg=#fffff3 hi Statement guifg=#8d6b5f guibg=#fffff3 hi Comment guifg=#777777 guibg=#fffff3 hi Identifier guifg=#2c2255 guibg=#fffff3 hi Constant guifg=#0f6d30 guibg=#fffff3 hi Special guifg=#de022a guibg=#fffff3 hi Cursor guifg=#de022a guibg=#c13a30
      Cheers, and thanks for the links!

      jeffa

        Exactly.

        This is the sort of config I would have expected to see years ago.

        I would tend to tone down the red; it still jumps out. But thanks for the constants, I think I'll take them and run with them for a while.

        --
        g r i n d e r
Re: (jeffa) 2Re: gvim syntax highlighting example)
by stefp (Vicar) on Nov 25, 2001 at 21:27 UTC
    Oh yeah, _PLEASE_ don't actually do what i just did and actually post gvim rendered HTML, as the resulting HTML increases in size tenfold. Guess that makes me a hypnotist.

    Oh, yes do it.You can't cut text in a gif save using OCR and I wonder which OCR software would be smart enough to deal with angry fruit salads :)
    By the way, how do you dump the html from vi?

    And sure enough, like said grinder below, Tufte books are mandatory reading.

    -- stefp