Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question
    
Can you create a ~/.vim/filetype.vim which sets the filetype to ruby for GEM files? – Scott Wilson Mar 14 '12 at 19:45
up vote 5 down vote accepted

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).

share|improve this answer
    
Thank you for the answer ! – Skydreamer Mar 15 '12 at 14:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .