2

I have emmet installed and some more plugins that are usable on html filetypes, I would like to have syntax highlighting and have indentation for jinja2 while keeping the filetype HTML so my HTML plugins work as they have to.

Is there any work around for this?

PD: I have tried vim-jinja2-syntax but it doesn't recognize .html with jinja2 inside + it only highlights {} not the if, for ... (and this is only when setting filetype to jinja manually)

1
  • 2
    Welcome to Vi and Vim! More details may help (e.g., which plugins specifically). You can edit to add this. (You might try the "hidden magic" of multiple filetypes: set filetype=html.jinja or whatever. I suspect something will go haywire (syntax? indentation?), but plugins should be available.)
    – D. Ben Knoble
    Aug 28 '20 at 18:39
1

You could use an autocmd to set the syntax to htmldjango when editing an HTML file:

autocmd FileType html set syntax=htmldjango

This preserves filetype while using the default htmldjango syntax file.

See:

:help :autocmd
:help 'syntax'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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