I've asked this question on StackOverflow and they suggested to ask it here. I am trying to set a custom syntax highlighting for BSD rc.conf file which looks like:


I created years agoo a syntax file:

if version < 600
  syntax clear
elseif exists("b:current_syntax")

if !exists("main_syntax")
  let main_syntax = 'sh'

if version < 600
  so <sfile>:p:h/sh.vim
  runtime! syntax/sh.vim
  unlet b:current_syntax

syntax case match

syn keyword rcconfKeywordYes YES
syn keyword rcconfKeywordNo NO

let b:current_syntax = "rcconf"

hi def link rcconfKeywordYes Type
hi def link rcconfKeywordNo Special

This worked before, but now in vim 8 it works only if there are spaces between keywords and other symbols:

name = YES
anothername = NO
  • 1
    So there is no highlighting at all of foo=bar? You say "years ago"...note that pre-vim 6 this was apparently not using the standard sh.vim syntax file so maybe that's the difference.
    – B Layer
    Commented Aug 26, 2020 at 13:14
  • 1
    Welcome to Vi and Vim!
    – D. Ben Knoble
    Commented Aug 26, 2020 at 13:24
  • 1
    Have you tried using dosini filetype? Commented Aug 26, 2020 at 14:31

1 Answer 1


It could depend on iskeyword value.
keyword only matches for a complete word, for example, if you define the keyword NO, it will not match NOT or PIANO.
If Vim considers = is a letter, then anothername=NO is a single word, and it's not NO.

You can check if Vim considers = to be a letter with :set iskeyword?.
You can probably fix it: with the command :set iskeyword-==, YES and NO will get colors.
With :set iskeyword+==, they lose they colors again.

You can also use the syntax iskeyword instead (it's not the same, for example it doesn't change abbrev behavior, and it is recommended to use this one).
It's explain at :help syntax|3546.
Try with: :syntax iskeyword @,48-57,192-255,$,_.

I don't know which one breaks your syntax, so you can try both.

  • 1
    Looks like you might be new here, but great couple of first answers! Welcome!
    – D. Ben Knoble
    Commented Aug 27, 2020 at 13:23
  • 2
    Thanks ! I already used stackexchange websites as "read only user" for at least several months, but only started giving answers since yesterday. Commented Aug 27, 2020 at 13:30
  • Thank you for answer. Unfotunatly it does not help. At the beginning iskeyword=@,48-57,_,192-255, after set iskeyword-== the same and no color, after set iskeyword+== the equal sign has been added iskeyword=@,48-57,_,192-255,= and no colors appeared also
    – dstep
    Commented Sep 7, 2020 at 16:28
  • what is the output of the command :syntax iskeyword ? Commented Sep 8, 2020 at 15:55
  • syntax iskeyword @,48-57,_,192-255,-
    – dstep
    Commented Sep 14, 2020 at 17:25

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.