Syntax Highlighting in Vim for Gemfile, Berksfile, and Vagrantfile
The Problem
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:
1
|
|
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
1
|
|
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.
The Solution
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!