0

Can you target a spesific line number in the gutter? Let's say I want line 20 in the gutter te be red for some reason. Possible? Like CursorLineNr, but defining the line number yourself. In short I'm looking to write a simple plugin showing some simple warnings through colours, not relying on the sign column feature. I use Neovim.

  • 1
    "not relying on the sign column feature" why this restriction? – Mass Mar 7 '19 at 17:59
  • I'm simply wondering if it's possible. The ability to colour individual lines of the gutter is a common feature of graphical editors. I strive to keep vim free of clutter, and I thought this would be a nice compromise. – Audun Olsen Mar 7 '19 at 18:30
  • But sign column was designed specifically for your purpose. And I have not seen any GUI editors where you can color specific line number, any example? Just curious. – klaus Mar 7 '19 at 18:42
  • 1
    If you're asking if it's possible, as in is there a setting without hacking the source code, then the answer is no. For further assurance, you don't even get CursorLineNr highlight if you don't use cursorline or relativenumber.But if you really need this settings, then you could hack something up so that the line numbers are part of the buffer itself and then you could use typical :h matchadd(). I mean when you're editing vim will add line numbers to the first column of each lines and when you save you have a keybinding that substitutes it with nothing. But this is a huge overhead! – klaus Mar 7 '19 at 20:09
  • 2
    Well, that is exactly what the sign column is for, so use it :) – Christian Brabandt Mar 8 '19 at 6:48
3

Works only in neovim

highlight CustomError ctermfg=red guifg=red
sign define error numhl=CustomError
sign place 2 name=error line=7

Have a look, at :h sign

asciicast

| 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.