1

One of my filetypes has a special comment format that has a background color, and it would be useful if I could extend the highlighting to extend that background to the terminal width, rather than just whatever EOL is in the buffer's line. So, for example, if I have an 80x50 terminal, and have a comment like this:

# This is a comment
this('is not');

Currently, the entire length of the buffer line is highlighted. I.e., # This is a comment has the syntax applied, as is normal. But I would like # This is a comment[~61 spaces] to be highlighted (the rest of the terminal line).

I don't think I can match part of a string that isn't there at all, so maybe there's a way to specify a CLREOL (ANSI \e[K) while still in the syntax color, or better yet, more portable/GUI-compatible equivalent?

1

Syntax highlighting can only match what's actually inside the buffer; it will end at the final character of a line (or wrap and continue with the next line).

I'd simply accept that as it is. The only alternative are hacks like messing with the ANSI escape codes in the terminal, or mis-using different Vim features to highlight the entire line: If you specify a linehl=... to :sign-define, that will cover the entire line, also past the end of text (but you'd have to maintain and update the sign positions yourself).

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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