I'm trying to create a basic custom syntax file for the first time, but I noticed that after I set a highlight link it's basically set and I'm not really sure how to change it. Here is my syntax file:

if exists("b:current_syntax")
    echom "Quitting"

syn keyword tTask       task start fix 
syn keyword tEnd        finish
syn keyword tNote       note

hi def link tTask Special
hi def link tEnd Todo
hi def link tNote Comment

let b:current_syntax = "todo"

In my .vimrc, I have au BufRead,BufNewFile *.todo setfiletype todo. When I change Comment to Special for example, the highlighting won't change in a file I've created. In fact... not much I've tried changes it. Is this a common problem? I couldn't find this online.

Edit: I "reopen" the todo file by using :edit in the tab, but closing and reopening in a new instance gives the same result where the highlighting doesn't change. I have put in echom commands, so I know that the code is running when I run :edit or open a new instance, but the highlighting doesn't change.

  • 1
    Are you editing the syntax file and then expecting a change? Or are you running a new highlight command? Exact steps/details would be helpful in pinning down what you expect vs. what's happening and how to get there. (I wouldn't recommend putting an echom in a syntax file. Also note that you can use the ftdetect directory for new filetypes. And that unlet statement seems spurious to me? You might also include a minimal vimrc with your problem; see How to debug my vimrc for help reducing it.)
    – D. Ben Knoble
    Commented Aug 3, 2021 at 16:36
  • @D.BenKnoble I am editing the syntax file (changing Comment to Special) and then re-opening a test.todo file I have created. I've put in echom commands in, and I know it runs, but nothing changes in the test.todo file. The unlet statement was a mistake (I had removed its matching let statement earlier), so I will update the question. The only relevant line in my vimrc is the autocmd statement that sets the todo filetype. Commented Aug 3, 2021 at 16:59
  • Define « re-opening ». Are you running :edit or opening a brand new vim instance? Please edit the question so this information does not get lost in the comments.
    – D. Ben Knoble
    Commented Aug 3, 2021 at 17:22
  • @D.BenKnoble Just added the information - sorry, I'm new to stackexchange forums. Commented Aug 3, 2021 at 17:40
  • No worries, welcome to Vi and Vim! If you haven't already, the tour and help center are good places to start
    – D. Ben Knoble
    Commented Aug 3, 2021 at 18:12

1 Answer 1


When you link groups using default it will only has effect once.

This is designed that way to provide default highlighting and possibility for end user to override it in their configs.

  1. syntax file provides some sane defaults
  2. user doesn't like it and overrides with hi link group1 group2
  3. syntax file using default doesn't override it back whenever syntax file is sourced again.

For your design phase, when you're not sure about what would be the best "sane" default there are several ways:

  1. :syn off and then :syn on
  2. or remove default from your hi definitions (but don't forget to return them once you're satisfied with result and want to distribute your syntax file)
  • Ah, that makes perfect sense. I looked through the vim help for highlight and couldn't find any of this. Thank you so much! Commented Aug 4, 2021 at 21:43

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.