I'm not getting highlighting syntax for .twig files..

48 views
Skip to first unread message

Javier Garcia

unread,
Apr 27, 2013, 9:41:49 AM4/27/13
to vim...@googlegroups.com
Hi,

I have installed .vim/syntax/htmljinja.vim and wrote this in my .vimrc:

au BufRead,BufNewFile *.twig set syntax=htmljinja

Any idea?

7.3.912

Javi

Phil Dobbin

unread,
Apr 27, 2013, 2:27:13 PM4/27/13
to vim...@googlegroups.com
On 27/04/2013 14:41, Javier Garcia wrote:

> Hi,
>
> I have installed .vim/syntax/htmljinja.vim and wrote this in my .vimrc:
>
> au BufRead,BufNewFile *.twig set syntax=htmljinja

Try:

'au BufRead,BufNewFile {*.twig} set ft=htmljinja'

Cheers,

Phil...




Gary Johnson

unread,
Apr 27, 2013, 2:39:04 PM4/27/13
to vim...@googlegroups.com
The {} are not necessary.

Regards,
Gary

Phil Dobbin

unread,
Apr 27, 2013, 5:05:34 PM4/27/13
to vim...@googlegroups.com
That's right. Only if you intend to add more than one file extension (I
copied & pasted it straight out of my vimrc & deleted as appropriate).

Cheers,

Phil...



Benji Fisher

unread,
Apr 28, 2013, 2:12:47 PM4/28/13
to vim...@googlegroups.com

     This advice comes down to "set the 'ft' option instead of the 'syntax' option."  I think that misses the point:  setting 'syntax' should work.

     Probably you do not have  a syntax file for htmljinja,  Last I checked, there is none included with the standard vim distribution.  Either download and install a syntax file for htmljinja or use something similar, like htmldjango (which is included in the standard distro).  While editing a .twig file, try

:set syntax=htmldjango

and see whether you like it.  If so, add an autocommand to your vimrc file.  If not, then make sure you have a syntax file for htmljinja.

     Another possibility:  if you *do* already have a syntax file for htmljinja and you added an autocommand to your vimrc file, did you  restart vim after editing vimrc?

HTH  --Benji Fisher

Javier Garcia

unread,
Apr 28, 2013, 5:03:08 PM4/28/13
to vim...@googlegroups.com, phild...@gmail.com
On Saturday, 27 April 2013 20:27:13 UTC+2, Phil Dobbin wrote:
> On 27/04/2013 14:41, Javier Garcia wrote:

> 'au BufRead,BufNewFile {*.twig} set ft=htmljinja'

Thanks, works!

Reply all
Reply to author
Forward
0 new messages