Vim Gemfile recognition

4

1

When I open a Gemfile in vim, I don't automatically get the colors for the code. I have to do manually :set syntax=ruby.

Is there a simple way to automate this ?

Cydonia7

Posted 2012-03-14T19:28:10.713

Reputation: 235

Can you create a ~/.vim/filetype.vim which sets the filetype to ruby for GEM files? – Scott C Wilson – 2012-03-14T19:45:29.757

Answers

6

If you are running Vim 7.3, or if you have installed a recent version of the vim-ruby plugin (any version newer than December 2009), then this should already be happening—they both arrange to set filetype=ruby for files named Gemfile.

If do not want to install vim-ruby, then you can still automatically use your existing Ruby support on files named Gemfile by putting this in your ~/.vimrc:

autocmd BufNewFile,BufRead Gemfile set filetype=ruby

You can skip this line if you decide to install vim-ruby to get the benefits of its updated indenting/highlighting/completion (vim-ruby automatically does the above autocmd).

Chris Johnsen

Posted 2012-03-14T19:28:10.713

Reputation: 31 786