ANN: New stable release - 2005.10.05

Doug Kearns dougkearns at
Thu Oct 6 08:13:43 EDT 2005

G'day Hugh,

On Thu, Oct 06, 2005 at 12:52:48AM +0100, Hugh Sasse wrote:
> On Wed, 5 Oct 2005, Doug Kearns wrote:
> > I've just sent up vim-ruby-2005.10.05.
> I've been trying this out and have come to the followint conclusion.
> In the ftdetect files you have 
> " eRuby
> au BufNewFile,BufRead *.rhtml                          setf eruby
> I think  that line should be:
> au BufNewFile,BufRead *.rhtml,*.erb                     set ft=eruby

Yes. I fixed this on 16/09/05. Have you not picked up the change as part
of the past few releases?
> Normally avoiding setf would be wrong, because :he setf says it is
> to prevent the filetype being set several times when sorting out the
> syntax etc.  [However, ideally for eruby files you still want the
> native syntax (whatever that happens to be) to still work.]  With
> vim/scripts.vim there is a did_filetype() call which, unless the
> filetype has been set, causes scripts.vim to exit.  Using setf
> instead of set filetype means that did_filetype "thinks" filetype
> has not been set, so overrides any decisions we have made up to now,
> setting, in my case, the filetype straight XML by examining the
> file's contents.

Yes, that's my understanding as well. This should be working with the
current release.
> .erb doesn't seem to be allocated to anything else.

I've left this out for the moment since I want to detect the 'host'
language for these *.erb files. From my initial investigations it
appears that it's safe enough to assume that *.rhtml is simply (X)HTML
with embedded Ruby. However, *.erb could be anything so I've decided to
just handle the *.rhtml files for now.

Do you think we should include it for 6.4; especially if the behaviour
is going to change? I'm assuming, at the moment, the biggest users of
this eRuby support will be/are RoRs people who seem to use *.rhtml
exclusively. I'm not sure users who are using *.erb files for other
purposes will be too keen on having them open up with HTML highlighting.
> What I can't figure out is whether one can properly support two
> syntaxes at the same time as per my statement in [] above.

It should be possible to dynamically merge them, in much the same way as
the existing eruby syntax file does, provided we can determine the host
filetype for non-HTML hosted eRuby files. 

If the file is named *.erb we'd need some way to determine the host

If the file is named as per usual then we'd need some way to specify
that it contains eRuby? We could add a script to ftdetect/ruby.vim which
simply looks for <% %> regions.

Then we'd need to think about merging ftplugins etc. This still isn't
quite right for *.rhtml yet either.

> would you want to?  Well, see for example page 93 of "Code
> Generation in Action" by Jack Herrington  [ISBN 1-930110-97-9]
> (and other examples therein) where ERB is being used to generate
> lots of repetitive C++ data structures.  You'd want the C++ syntax
> to be correcly highlighted as well as the embedded ruby, if
> possible.   [For completeness the website is at:
> , but I don't see many examples of the use of eruby with C++ there.]

Yes, eRuby seems like a reasonable templating solution so I expect that
its uses are varied.
> I'm not seeing much on the net to point you at either -- any idea
> how to make Google do what we want with "C++" instead of treating it
> as C?

"C++" - actually in quotes should work.

More information about the vim-ruby-devel mailing list