Limiting or changing the color of a specific line in Vim

I am using Vim for git. I created .gitcommittemplate

:

############################### <BASLIK> ###############################
#
# ...
#
# |--En fazla 50 Karakter olabilir(Max 50 Char)--|
my real title

my real body

      

I want to limit string 6 to 50 characters. Or even better, after 50 characters convert it to red and limit it to 72 characters.

How can i do this?

+3


source to share


1 answer


For highlighting try this:

highlight LineSix guifg=red ctermfg=red
syntax match LineSix /\%6l\%51c.*/

      

This creates a new highlight group named LineSix and then sets it red in the GUI or Terminal. Then he says that whatever matches this regex is the selection group.

Regular expression uses pleasure magic. Here's the breakout:

\%6l

      



will match anything on line 6 (try :h /\%l

)

\%51c

      

will match anything in column 51 (try it :h /\%c

)

and then it .*

will obviously match something.

As for the limit of more than 75 characters, I don't think it is possible. You can try installing textwidth

and colorcolumn

, but that doesn't force you to use less than 75 characters, and they won't apply to a single line.

+4


source







All Articles