Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby-like Syntax Highlighting in VIM for Thor

How can I configure vim to use the same syntax highlighting for Thor as it does for ruby? When I'm editing a *.thor file, I can use :set syntax=ruby, which works, but is not permanent. Is there a way to do something in my .vimrc file to conditionally set the syntax to ruby if it's *.thor? Maybe create a thor syntax file and inherit from ruby?

like image 684
Peter Brown Avatar asked Jan 27 '11 22:01

Peter Brown


People also ask

Does vim support Ruby?

VimScript provides the ruby command that can be used to execute some Ruby code. Instead of using another VimScript function we can instead refer to it as a Ruby function or executed Ruby code. For a single line of Ruby code we can use the ruby command followed by your Ruby code.

How do I add highlighting code in Vim?

After opening login.sh file in vim editor, press ESC key and type ':syntax on' to enable syntax highlighting. The file will look like the following image if syntax highlighting is on. Press ESC key and type, “syntax off” to disable syntax highlighting.

What is Vim in Ruby?

The facts: Vim is the number one code editing tool for Ruby developers. Ruby has its own tool. If you're wondering what text editor or IDE rubyists are using, you might think that they are using their own dedicated editor. JetBrains, the company behind IntelliJ, is offering in this matter RubyMine.


1 Answers

au BufRead,BufNewFile *.thor set filetype=ruby

I think should suffice... maybe this if you want to customize it later:

au BufRead,BufNewFile *.thor set filetype=thor
au! Syntax thor source $HOME/.vim/syntax/thor.vim

and copy ruby .vim syntax highlight file to $HOME/.vim/syntax/thor.vim

like image 184
Mikhail Avatar answered Oct 01 '22 09:10

Mikhail