Vim: using <afile> in autogroup command

My goal is to highlight the <basename>.<extension>.erb , since I would like to highlight the <basename>.<extension> files.

As a first pass, I'm fine with <basename>.<filetype>.erb , which I tried to do with

 au BufNewFile,BufRead *.erb setf <afile>:r:e 

But this does not seem to work. What should I do?

+4
source share
2 answers

It seems that the extension of a special character is only performed when typing a command. However, you can call the expand function.

  au BufNewFile,BufRead *.erb setf=expand("<afile>:r:e") 

Should answer your question (but it doesn't seem to work for what you want to do).

+1
source

Try the following:

autocmd BufNewFile, BufRead *. *. erb execute 'doautocmd BufRead'. expand (': g')

0
source

All Articles