It all started when I was editing a Vagrantfile and making more customization. It is simply ruby and having syntax highlighting in it will be easier to edit the file. I always see the following line in the Vagrantfile:
but it didn’t seem to do anything for the syntax highlighting. I tried to set the filetype for the Vagrantfile when I was in the editor using
it worked like a charm. But I don’t want to do it every time I enter the file. Also I have the same problem with the Gemfile as well as the Berksfile.
I did some research and figured out that I can achieve this using the
autocmd in vimrc. So added the
following lines to my vimrc.
1 2 3
So whenever I open any of these files, they are highlighted as ruby files and I am happy!