Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 4 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.