When opening a bind zone file, I have to type by hand :set ft=bindzone to get syntax highlighting. It's not set automatically on load.

On another hand others filetypes (such as php, perl or kind) are properly set.

Where I should look first to solve this ?


the filetype bindzone is supported by default in Vim using the filetype.vim in $VIMRUNTIME which sets the filetype according to the properties of your file. By default however, Vim only sets the filetype to bindzone if the file is called named.root and for any file that has the extensions .db and the first 4 lines match this regex:

'^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA'

If your files do not match that, consider renaming them (if that is the cause for not detecting it properly), add a modeline as shown by @grodzik or enhance the filetype detection logic (see the faq question 26.8).

Also, in case you suspect a bug in the default filetype.vim file, consider creating a PR at the vim/vim repository suggesting a fix for that.


filetype is set based on the file extension or by ftdetect plugins. For example PHP files end with .php and Vim loads if it exist a file php.vim from directories like ftplugin, syntax etc (they need to be in Vim's runtime paths). So your files either should have extension .bindzone or if they have different extension then you can link in your $HOME/.vimrc/syntax/<extension>.vim pointing to where the bindzone syntax file is.

You can also add modeline in those files with set ft=bindzone. A modeline is first or last line in a file that is a valid comment for that file type and contains something like this: vim: set ft=bindzone: (there can be more settings there). See :help modeline for more info.

Another solution would be to add autocmd that will set file type for files matching a pattern, for example all files in particular directory:

au BufRead,BufNewFile /path/to/bind/zone/files/* set ft=bindzone

One more solution is to write a ftdetect plugin, but I don't have experience with that. You can checkout files in ftdetect directories for more info or the Vim's help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.