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.

6
  • 1
    "not relying on the sign column feature" why this restriction?
    – Mass
    Mar 7, 2019 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. Mar 7, 2019 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.
    – 3N4N
    Mar 7, 2019 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!
    – 3N4N
    Mar 7, 2019 at 20:09
  • 2
    Well, that is exactly what the sign column is for, so use it :) Mar 8, 2019 at 6:48

1 Answer 1

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

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.