I have a file with the extension *.upf in which the # is not highlighted. I use # for comments. :syntax on also doesn't seem to work.

The issue here is I have a file (*.upf) which is generated by design compiler which has ## being highlighted but if I make a manual file (*.upf) I don't see it highlighted.

  • 3
    In the file that gets highlighted, check the output of :set syntax? filetype? If this returns something, than vim detected it as a type to highlight. Than you set need to use :set ft=<return_value_from_previous_command>. If it didn't detect it, you may try some generic ones, like :set ft=conf Dec 29, 2021 at 8:29
  • 1
    Welcome to Vi and Vim!
    – filbranden
    Dec 29, 2021 at 16:38

1 Answer 1


Vim doesn't have anything related to .upf file extension out of the box.

No syntax files, no filetypes. You can check it by navigating to :e $VIMRUNTIME/syntax or/and by checking filetype detection rules in :e $VIMRUNTIME/filetype.vim.

So the question is how in the first place you have ## highlighted in .upf file generated by some program. Did you install some third-party ftplugin?

If you want to add custom syntax highlighing...

add to vimrc

augroup UPF | au!
    au BufRead,BufNew *.upf set filetype=upf
augroup END

create/add to ~/.vim/syntax/upf.vim

if exists("b:current_syntax")

let s:cpo_save = &cpo
set cpo&vim

syn match upfComment "^\s*#\s.*$" contains=@Spell

hi def link upfComment Comment

let b:current_syntax = "upf"

let &cpo = s:cpo_save
unlet s:cpo_save
  • 1
    Likely the # triggered the conf filetype
    – D. Ben Knoble
    Dec 30, 2021 at 0:10

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.