I have text files which have extensions *.sc. So to make syntax highlighting for some of the keywords in that type of text files I created ~/.vim/syntax/sc.cim. Below is the file content.

user $ cd ~/.vim/syntax/
user $ cat sc.vim 
" Syntax highlightor file for files ending in *.sc
syn keyword basicLanguageKeywords interface channel behavior
user $

Also I added following line to ~/.vimrc

au BufRead,BufNewFile *.sc set filetype=sc

Now I was hoping that when I do :set syntax=sc in vim, the syntax highlighting would be in effect for *.sc files. But it is not working.

What is wrong here ?

  • What are your filetype settings?
    – muru
    Commented Nov 21, 2015 at 9:17
  • where ? in ~/.vimrc ?
    – sps
    Commented Nov 21, 2015 at 9:18
  • I have just this one line. filetype on in it.
    – sps
    Commented Nov 21, 2015 at 9:19
  • And your syntax setting? If filetype on is set, you shouldn't have to do set syntax=sc.
    – muru
    Commented Nov 21, 2015 at 9:20
  • 1
    Both of them look right. But have you defined a highlight setting for basicLanguageKeywords? Try :highlight basicLanguageKeywords ctermfg=blue, and see if your keywords show up in blue.
    – muru
    Commented Nov 21, 2015 at 9:28

1 Answer 1


If you create your own syntax group names, like basicLanguageKeywords, then you'll have to create highlight settings for them. Stick to commonly used names so that your syntax settings work with most colour schemes. Checkout :h group-name:

To be able to allow each user to pick his favorite set of colors, there must
be preferred names for highlight groups that are common for many languages.
These are the suggested group names (if syntax highlighting works properly
you can see the actual color, except for "Ignore"):
    *Comment        any comment

    *Constant       any constant
     String         a string constant: "this is a string"
     Character      a character constant: 'c', '\n'
     Number         a number constant: 234, 0xff
     Boolean        a boolean constant: TRUE, false
     Float          a floating point constant: 2.3e10

    *Identifier     any variable name
     Function       function name (also: methods for classes)

    *Statement      any statement
     Conditional    if, then, else, endif, switch, etc.
     Repeat         for, do, while, etc.
     Label          case, default, etc.
     Operator       "sizeof", "+", "*", etc.
     Keyword        any other keyword
     Exception      try, catch, throw

In this case, that would be Keyword.

  • I added line hi def link basicLanguageKeywords Keyword in ~/.vim/syntax/sc.vim and it is working now.
    – sps
    Commented Nov 21, 2015 at 10:00
  • 1
    @sps you might have just named your group Keyword directly: syn keyword Keyword interface ....
    – muru
    Commented Nov 21, 2015 at 10:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .