Loading ...
Sorry, an error occurred while loading the content.

How to colorize columns?

Expand Messages
  • Grap Klobber
    Is there a way to colorize fixed-width columar data using Vim? I.e., the first 4 characters in green, next 9 in yellow, etc. (or alternating black and white)
    Message 1 of 5 , Apr 30, 2003
    • 0 Attachment
      Is there a way to colorize fixed-width columar data using Vim?

      I.e., the first 4 characters in green, next 9 in yellow, etc. (or
      alternating black and white)




      _________________________________________________________________
      The new MSN 8: smart spam protection and 2 months FREE*
      http://join.msn.com/?page=features/junkmail
    • Charles E. Campbell
      ... Yes. Regards, Chip Campbell P.S. Hmm, here s how to do it with green foreground throughout and the background alternating between black and blue, out to
      Message 2 of 5 , Apr 30, 2003
      • 0 Attachment
        On Wed, Apr 30, 2003 at 06:07:50PM +0000, Grap Klobber wrote:
        > Is there a way to colorize fixed-width columar data using Vim?
        >
        > I.e., the first 4 characters in green, next 9 in yellow, etc. (or
        > alternating black and white)
        ---------------------------------------------------------------------

        Yes.

        Regards,
        Chip Campbell

        P.S. Hmm, here's how to do it with green foreground throughout and
        the background alternating between black and blue, out to about
        130 columns. Change maxcol to get more or fewer.
        ---------------------------------------------------------------------
        syn clear
        let icol = 11
        let maxcol = 130
        syn match ColOdd "^.\{1,10}"
        while icol < maxcol
        exe 'syn match ColEven "\%'.icol.'c.\{1,10}"'
        let icol= icol + 10
        exe 'syn match ColOdd "\%'.icol.'c.\{1,10}"'
        let icol= icol + 10
        endwhile
        hi ColOdd gui=NONE cterm=NONE ctermfg=green guifg=green ctermbg=black guibg=black
        hi ColEven gui=NONE cterm=NONE ctermfg=green guifg=green ctermbg=blue guibg=blue
        hi ColOdd cterm=NONE
        hi ColEven cterm=NONE
        ---------------------------------------------------------------------

        --
        Charles E Campbell, Jr, PhD _ __ __
        Goddard Space Flight Center / /_/\_\_/ /
        cec@... /_/ \/_//_/
        PGP public key: http://www.erols.com/astronaut/pgp.html
      • Grap Klobber
        :source -ing this inside of vim get: Error detected while processing cols.vim: line 12: Not an editor command: guibg=black line 14: Not an editor command:
        Message 3 of 5 , May 1, 2003
        • 0 Attachment
          ":source"-ing this inside of vim get:

          Error detected while processing cols.vim:
          line 12:
          Not an editor command: guibg=black
          line 14:
          Not an editor command: guibg=blue


          Please pardon what must be a newbie problem.



          >From: "Charles E. Campbell" <cec@...>
          >To: Grap Klobber <grapklobber@...>
          >CC: Vim <vim@...>
          >Subject: Re: [vim] How to colorize columns?
          >Date: Wed, 30 Apr 2003 15:32:46 -0400
          >
          >On Wed, Apr 30, 2003 at 06:07:50PM +0000, Grap Klobber wrote:
          > > Is there a way to colorize fixed-width columar data using Vim?
          > >
          > > I.e., the first 4 characters in green, next 9 in yellow, etc. (or
          > > alternating black and white)
          > ---------------------------------------------------------------------
          >
          >Yes.
          >
          >Regards,
          >Chip Campbell
          >
          >P.S. Hmm, here's how to do it with green foreground throughout and
          > the background alternating between black and blue, out to about
          > 130 columns. Change maxcol to get more or fewer.
          > ---------------------------------------------------------------------
          >syn clear
          >let icol = 11
          >let maxcol = 130
          >syn match ColOdd "^.\{1,10}"
          >while icol < maxcol
          > exe 'syn match ColEven "\%'.icol.'c.\{1,10}"'
          > let icol= icol + 10
          > exe 'syn match ColOdd "\%'.icol.'c.\{1,10}"'
          > let icol= icol + 10
          >endwhile
          >hi ColOdd gui=NONE cterm=NONE ctermfg=green guifg=green ctermbg=black
          >guibg=black
          >hi ColEven gui=NONE cterm=NONE ctermfg=green guifg=green ctermbg=blue
          >guibg=blue
          >hi ColOdd cterm=NONE
          >hi ColEven cterm=NONE



          _________________________________________________________________
          STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
          http://join.msn.com/?page=features/junkmail
        • Aschwin Marsman
          ... Looks like a word wrap problem of a mail application, these lines should be at the end of the previous lines. ... The line above should be at the end of
          Message 4 of 5 , May 1, 2003
          • 0 Attachment
            On Thu, 1 May 2003, Grap Klobber wrote:

            > ":source"-ing this inside of vim get:
            >
            > Error detected while processing cols.vim:
            > line 12:
            > Not an editor command: guibg=black
            > line 14:
            > Not an editor command: guibg=blue

            Looks like a word wrap problem of a mail application, these
            lines should be at the end of the previous lines.

            > Please pardon what must be a newbie problem.
            >
            >
            >
            > >From: "Charles E. Campbell" <cec@...>
            > >To: Grap Klobber <grapklobber@...>
            > >CC: Vim <vim@...>
            > >Subject: Re: [vim] How to colorize columns?
            > >Date: Wed, 30 Apr 2003 15:32:46 -0400
            > >
            > >On Wed, Apr 30, 2003 at 06:07:50PM +0000, Grap Klobber wrote:
            > > > Is there a way to colorize fixed-width columar data using Vim?
            > > >
            > > > I.e., the first 4 characters in green, next 9 in yellow, etc. (or
            > > > alternating black and white)
            > > ---------------------------------------------------------------------
            > >
            > >Yes.
            > >
            > >Regards,
            > >Chip Campbell
            > >
            > >P.S. Hmm, here's how to do it with green foreground throughout and
            > > the background alternating between black and blue, out to about
            > > 130 columns. Change maxcol to get more or fewer.
            > > ---------------------------------------------------------------------
            > >syn clear
            > >let icol = 11
            > >let maxcol = 130
            > >syn match ColOdd "^.\{1,10}"
            > >while icol < maxcol
            > > exe 'syn match ColEven "\%'.icol.'c.\{1,10}"'
            > > let icol= icol + 10
            > > exe 'syn match ColOdd "\%'.icol.'c.\{1,10}"'
            > > let icol= icol + 10
            > >endwhile
            > >hi ColOdd gui=NONE cterm=NONE ctermfg=green guifg=green ctermbg=black
            > >guibg=black

            The line above should be at the end of the previous line.

            > >hi ColEven gui=NONE cterm=NONE ctermfg=green guifg=green ctermbg=blue
            > >guibg=blue

            Same here, the line above should be at the end of the previous line.

            > >hi ColOdd cterm=NONE
            > >hi ColEven cterm=NONE

            Kind regards,

            Aschwin Marsman

            --
            aYniK Software Solutions all You need is Knowledge
            Bedrijvenpark Twente 305 NL-7602 KL Almelo - the Netherlands
            telephone: +31 (0)546-581400 fax: +31 (0)546-581401
            a.marsman@... http://www.aYniK.com
          • Charles E. Campbell
            ... I agree with Aschwin Marsman; your email client is doing things for (to?) you, ie. word wrapping. Doesn t help with code. Both of the guibg=black s
            Message 5 of 5 , May 1, 2003
            • 0 Attachment
              On Thu, May 01, 2003 at 05:49:10PM +0000, Grap Klobber wrote:
              > ":source"-ing this inside of vim get:
              >
              > Error detected while processing cols.vim:
              > line 12:
              > Not an editor command: guibg=black
              > line 14:
              > Not an editor command: guibg=blue
              >
              > Please pardon what must be a newbie problem.
              ---------------------------------------------------------------------

              I agree with Aschwin Marsman; your email client is doing things for
              (to?) you, ie. word wrapping. Doesn't help with code. Both of the
              "guibg=black"s should be on the end of the previous line, not on new
              lines of their own.

              The easiest thing would just be edit the file and to appropriately
              join the lines that need joining. Alternatively, apply uudecode and
              gunzip to the stuff between ----s below:

              ---------------------------------------------------------------------
              begin 600 colorcolumn.gz
              M'XL(`')QL3X``Y6/30Z",!"%U_84$Q+3A8;0N+4KPQ8N0$Q*&0NQE(0?Q1CO
              M+K1`-+K0W9N9][Z9:6X&I$91$XTM%++2`,"!,5N7HA\[0[T+2#-82]'*'`Z5
              MCK-LY1W]Y,ZV+'AXY)H7&EU^/\4(8(]`WV+A!<W*2];4'ZT^E0N!$I@OX(ZS
              M`19\8]C5?R#09/8ZDA=S7+98ER?%58UH0'7%HNTD53S50I['R:OF41R%SN+D
              5A+1?_<+L$!;FI#^93SN3P,F3`0``
              `
              end
              ---------------------------------------------------------------------

              Regards,
              Chip Campbell

              --
              Charles E Campbell, Jr, PhD _ __ __
              Goddard Space Flight Center / /_/\_\_/ /
              cec@... /_/ \/_//_/
              PGP public key: http://www.erols.com/astronaut/pgp.html
            Your message has been successfully submitted and would be delivered to recipients shortly.