--
Blog: http://stardiviner.tumblr.com/
Homepage: http://stardiviner.dyndns-blog.com
Love Linux -> love code -> like this.
> On Jul 12, 8:38 am, stardiviner wrote:
>> how to add a colored line behind line number.
>> here is the example:http://blog.nguyenvq.com/2011/06/29/some-custom-emacs-keybindings-for...
>>
>
> Are you asking for every other line to be highlighted in a different
> color as shown in the screen shot?
I assumed the request was for the red, vertical bar after (= "behind")
the line number.
I couldn't see a straightforward way to do it. My first attempt was to
subvert the 'signs' columns, but I couldn't figure out a nice way to
activate the column without actually adding signs. And after doing so I
discovered that it appears to the left of the numbers anyway.
--
Best,
Ben H
You could possibly hack something like this:
1) Add a space at the beginning:
:%s/^/ /
2) Match the first column
call matchadd('Conceal', '^ ')
3) change syntax highlighting for the conceal highlighting group
hi Conceal ctermbg=Red ctermfg=Red
You need to adjust the color to your taste and depending on whether
you use terminal vim or gvim, you need to use cterm(bg,fg) (for the former)
or gui(bg,fg) for the latter.
regards,
Christian
I tried once using several
:syn match Evenl /.*/ nextgroup=Oddl
:syn match Oddl /.*/ nextgroup=Evenl
:hi Evenl ctermbg=Red ctermfg=Black
:hi Oddl ctermbg=Yellow ctermfg=Black
Unfortunately, this did not work. I am not sure why. My understanding
of the syntax highlighting was, that the nextgroup parameter should
force matching the next group. But somehow it ends always matching the
same group. Not sure if this is a bug or my understanding is wrong.
> There is no way to highlight entire lines, including empty space and
> line numbers, alternating between two different backgrounds. At least,
> not without modifying Vim's C code and recompiling.
> There is no way to highlight entire lines, including empty space and
> line numbers, alternating between two different backgrounds. At least,
> not without modifying Vim's C code and recompiling.
That is not entirely true. If you set up signs, you can highlight
entire lines. I have made a simply plugin that makes that possible:
http://www.vim.org/scripts/script.php?script_id=2998
regards,
Christian
Yes, this works. Thanks for pointing me to the obvious ;)
regards,
Christian
It works, but overrides your existing syntax rules (I guess because of
:h syn-priority). And it get's empty lines wrong.
Mit freundlichen Gr��en
Christian