I’ve been asked this question quite a few times, so I thought I might as well add it here, just in case it helps someone out there..
You may have noticed that Vim supports zsh files, but that files with the extension
.zsh don’t get their syntax highlighted by default. That is simple to fix (as with most things in Vim). Simply add this to your ~/.vimrc:
autocmd BufNewFile,BufRead *.zsh setlocal filetype=zsh
Once you have added this, you can try something like
vim somefile.zsh. The zsh ftplugin should now be loaded, and you should get your syntax highlighted. This of course assumes that you have enabled syntax highlighting (
syntax on) as well as file-type plug-ins (
filetype plugin on).
You can use the same principle for other files or file patterns as well. In my vimrc file you will find the following line:
autocmd BufNewFile,BufRead vimoutlinerrc setlocal filetype=vim
because I use the Vim outliner, and vim doesn’t (yet) recognize the file
vimoutlinerrc to be a vim file.
An alternative to adding a bunch of
autocmds to your vimrc would be to use modelines (see :help modeline if you don’t know what a modeline is). But I personally don’t like to add modelines to my files. Feel free to use which ever solution suits you best.