GVim: Different colors of odd and even lines
Can I create color scheme f开发者_运维问答or GVim (MacVim) where odd lines and even lines will have different colors?
A Google search turned this up (I didn't know how to do it, but your question made me curious). Post below.
Got it to work on text files, as follows (on W32)
---- ~/vimfiles/after/syntax/text.vim
hi default Oddlines ctermbg=grey guibg=#808080
hi default Evenlines cterm=NONE gui=NONE
syn match Oddlines "^.*$" contains=ALL nextgroup=Evenlines skipnl
syn match Evenlines "^.*$" contains=ALL nextgroup=Oddlines skipnl
---- $VIM/vimfiles/after/filetype.vim
augroup filetypedetect
au BufRead,BufNewFile *.txt setf text
augroup END
---- ~/vimfiles/colors/almost-default.vim
[...]
hi Oddlines ctermbg=yellow guibg=#FFFF99
hi Evenlines ctermbg=magenta guibg=#FFCCFF
[...]
Notes: 1. filetype.vim in an "after-directory" and with ":setf" to avoid overriding already-detected "special" .txt files.
With "default" before the highlight name in the syntax file (but not without it) the colors from the colorscheme (invoked from the vimrc) are used. (Without a colorscheme, the "default" colors from the syntax file are still used.)
Haven't succeeded (but haven't much tried) to make it work for a more complex filetype with an already defined syntax like HTML
After entering the above changes, Vim must be restarted for them to take effect.
OK, enough for now, I'm taking a nap. Best regards, Tony.
精彩评论