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

129360Re: Alternating lines' color

Expand Messages
  • Ben Fritz
    Mar 2, 2012
      On Mar 2, 12:01 pm, Marco <gae...@...> wrote:
      > On Fri, Mar 2, 2012 at 6:39 PM, Benjamin Fritz <fritzophre...@...> wrote:
      > > Script attached to make odd and even lines have a different background
      > > color. Simply source this script in your .vimrc and define a highlight
      > > for EvenLbg to use.
      >
      > Hi,
      >
      > ok for sourcing, but I am not really vimscript-prone: what is that
      > EvenLbg you mention?
      > (yeah, I have seen it in the script!).
      >

      The script I attached will set up a :sign on every even line, to allow
      it to work without interfering with syntax definitions, and to
      highlight the entire line (even places in the line where there is no
      text). The threads I refer to also show how to do it with syntax
      definitions (which will interfere with existing syntax but be much
      faster), or with matchadd() (which will not interfere with existing
      syntax), however neither of these color the entire line, they only
      color the part of the line with text in it.

      The signs defined by the script will use the color defined by the
      EvenLbg highlight group. This group does not exist by default. You
      will need to add a highlight definition similar to the highlight
      definitions in colorscheme scripts. For example,

      :hi EvenLbg guibg=DarkRed

      or

      :hi EvenLbg guibg=#c0ffee

      You will need to define this highlight group in a way which does not
      get overwritten by your chosen colorscheme, assuming you have one.

      One option is to add this definition to your .vimrc in a ColorScheme
      autocmd:

      autocmd ColorScheme * hi EvenLbg guibg=#c0ffee

      Another option is to actually edit your chosen colorscheme to add this
      line (preferably editing a copy placed in ~/.vim/colors on Unix, or
      $HOME/vimfiles/colors on Windows; not the version in your runtime
      files).

      If you do not use any colorscheme you can just add the command to
      your .vimrc directly.

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 12 messages in this topic