I'm having trouble configuring Vim on Manjaro:

After setting syntax on at .vimrc file, I make a Prolog program (bug.pl) which shows no syntax highlight:

enter image description here

But after I append /**/ to top of file (then quit and restart vim), highlighting somehow works:

(/**/ is comment in Prolog, same like that of C)

enter image description here

So how do I have highlight without that useless /**/?




VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 6 2017 14:13:23)


Suggested by grodzik, it's about filetype conflict.

I fix it by adding au FileType perl set filetype=prolog to my .vimrc. (Make sure it's AFTER syntax on)

Now I see highlight.

3 Answers 3


This is because by default a file with extension .pl is for Perl files. If you open your file, when there is no /**/ on first line and run command :set filetype?, it will show perl, not prolog.

However, if you add /**/ on the first line, than there is probably some code inside Vim's standard distribution, that detects that and sets file type as prolog - again, check it with :set filetype?

If you know that you won't need perl syntax highlighting, than you can add to .vimrc:

au FileType perl set filetype=prolog

but rember, that this will disable perl file type for good. I think that better way is to prepend a file with that /**/, and let Vim detect the correct file type.

  • I do add au FileType perl set filetype=prolog to my .vimrc, and set filetype? return filetype=prolog. Still I see plain text without highlight. How do I do?
    – Rahn
    May 12, 2017 at 8:19
  • Do you still have syntax on in your .vimrc?
    – grodzik
    May 12, 2017 at 8:30
  • 1
    I copy syntax on to the line before au FileType ... then it works
    – Rahn
    May 12, 2017 at 8:36

grodzik has already explained why this occurs, but I disagree with his suggested solution. As he explains, using his autocommand means that it will be impossible ever to use the perl file type. Even if you believe you will never want to view a Perl file, this still seems unnecessarily final.

A gentler solution is to just set the filetype directly for files with .pl extensions. You can then still set the perl filetype manually with the command :set filetype=perl if necessary.

The Vim documentation describes how to do this in :help new-filetype, section C. In short:

Create a file ~/.vim/filetype.vim with the contents:

" my filetype file
if exists("did_load_filetypes")
augroup filetypedetect
  au! BufRead,BufNewFile *.pl setfiletype prolog
augroup END

I also just have been editing prolog file and discovered that there is something with default syntax highlighting. So I checked out he :h filetype and found the next:

enter image description here

So I added % vim: set filetype=prolog : to my prolog file and everything works now!

enter image description here

Sorry, I am a little late with the answer, but anyways... :)

  • The /* */ aren’t needed. That’s probably an example C or Java modeline. :help modeline
    – D. Ben Knoble
    Mar 30, 2023 at 21:08
  • @D.BenKnoble Thanks! All fixed now. Mar 31, 2023 at 8:18
  • @VladyslavRehan What font are you using? That looks interesting.
    – Rahn
    Apr 2, 2023 at 15:23
  • @Rahn Glad You asked. I am using Fantasque Sans Mono (normal) font. Apr 2, 2023 at 19:04
  • @VladyslavRehan Thanks! Using it now!
    – Rahn
    Apr 4, 2023 at 15:15

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.