开发者

How do I specify that I want Vim to treat .ru files like .rb files

Whenever I use Vim with Ruby files, I get nice coloring and automatic indention on blocks. However, when I am editing a Rack file, I don't get thes开发者_运维问答e things. How can I extend my Vim/Ruby configuration with my Rack files?


Put this in your vimrc to tell vim to associate *.ru files with ruby syntax highlighting.

au BufRead,BufNewFile *.ru setfiletype ruby


Ensure the following lines are in your vimrc file:

syntax on
filetype on
au BufNewFile,BufRead *.ru set filetype=ruby

The first two are probably already set if other files are syntax-colored, but I've put them there anyway.

The final one sets automatic actions on creating a new file and opening an existing file, to set the file type based on the extension.


You can install the vim-ruby plugin by tpope, which will do this and much more!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜