1

I understand that vim can set syntax for highlighting by defining the classes.

However, this is a bit tedious.

Is there an easy way to change the background of a line, e.g. is there a way by writing

This is the line. ///LightBlue///

, the background color would be light blue?

2 Answers 2

1

I would do:

highlight LightBlue guibg=#00afff ctermbg=039
match LightBlue /^.*lightblue.*$/

Where the pattern: ^.*lightblue.*$ is identifying the lines that you would like to highlight in light blue (in this example all the lines that contains lightblue).

4
  • thanks a lot! works like a charm
    – athos
    Commented Mar 21 at 16:55
  • Thanks for the feedback :-) Commented Mar 21 at 21:10
  • is there a limitation that we can't have two highlights, e.g. one lin of lightblue and another with lightgreen?
    – athos
    Commented Mar 23 at 20:32
  • 1
    The :match call override each other but with the syntax call you can have concurrent highlighting (that shouldn't overlap each other though). Commented Mar 23 at 20:37
1

Using :highlight commands, only changes those parts of a line, that have content. The empty lines won't be colored.

A few years ago, I created a plugin BackgroundColor, that allows to highlight the complete line using Signs.

With that, you can have real background colors like this: enter image description here

Just use the ex commands :Green, :Blue etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.