The option colorcolumn is really useful. I would like a similar result to what it yields but only for the two lines that are at the top and the bottom of the screen (not the document, but the screen). Is there a way to achieve that?

More generally, is it possible to highlight or colorize a set of positions with row-column coordinates (row_i, col_i), i = 1,...,N (again, those coordinates correspond to positions in the visible screen at any time, not the document)?

  • If you want to highlight screen line, you need to update highlighting area as you scroll up or down, I'm not sure if vim has this kind of "scroll event".
    – dedowsdi
    Apr 6, 2019 at 12:52
  • No, it's not possible. All the highlight related commands are based on the active buffer that is displayed on the window. You have to understand, there is no reason for highlight to be used on empty buffer. Maybe if you have some use cases for why you want that, we can suggest some alternatives
    – 3N4N
    Apr 6, 2019 at 13:56
  • Not really needing it but just wondering. I would gladly accept (give the green tick) the 'no' as an answer if any proof, reference or hint is given.
    – Godoy
    Apr 6, 2019 at 14:15

1 Answer 1


Hightlight first and last 2 lines after column 80:

:autocmd VimEnter,WinEnter * :match Error /\v%>80v%<3l.*|%>80v.*%$|%>80v.*(\n.*%$)@=/

You need to open a new window or reopen vim for this to work.


  • %>80v%<3l.* match everything after column 80 in first 2 lines
  • %>80v.*%$ match everything after column 80 in last line
  • %>80v.*(\n.*%$)@=/ match everything after column 80 in last second line
  • :help :match
  • :help /\%v
  • :help /\%l


This solution doesn't work on screen line.

  • Thanks, but that is not what I was asking for. That only highlights some characters in the two first and last lines of the document, but not of the visible screen. I edited the question to clarify it.
    – Godoy
    Apr 6, 2019 at 12:28
  • 1
    Those kind of graphics aren't really possible in Vim @Godoy; I'm afraid this is the closest you can get. Also see Is it possible to use two different color backgrounds in a single vim buffer?, which is essentially the same root problem ("colourize something without text"). Apr 16, 2019 at 7:40

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.