MacVim overrides default filetype.vim when assigning file types

In the standard filetype.vim that comes with MacVim , I have the following:

 au BufNewFile,BufRead *.erb,*.rhtml setf eruby 

I installed MacVim using Homebrew and I installed Janus . Following Janus instructions, I created ~/.vimrc.local to store my local settings. I want to set filetype for *.html.erb files to html.eruby.eruby-rails , so I added the following line to ~/.vimrc.local .

 autocmd BufNewFile,BufRead *.html.erb setf html.eruby.eruby-rails 

However, it looks like the file type is still selected by MacVim default filetype.vim instead of filetype.vim my change to ~/.vimrc.local .

What do I need to do differently so that MacVim correctly designates *.html.erb files as filetype html.eruby.eruby-rails without changing the default filetype.vim ?

+4
source share
2 answers

Change setf in your autocmd to set ft= . If you look at :help setf , it says that it will not set the file type if it is already installed elsewhere.

+7
source

Well, I tried the following and it seems to work:

 autocmd FileType eruby set ft=html.eruby.eruby-rails 

However, if I understand correctly, this is a change to all files, which by default filetype.vim stands for eruby for the file type html.eruby.eruby-rails .

+1
source

Source: https://habr.com/ru/post/1340976/


All Articles