Most of my edits are done in .html files. However, I write a lot of jinja code and css in these html files.

Problem 1: Jinja Indentation

whenever I have a bloc such as this:

{{ my_macro(arg1, arg2, arg3) }} 

My ideal level of indentation will be:

<previous line indents here> 
{{ my_macro(arg1,
            arg3) }} 

However, right now I am seeing this level of indentation in my vim :

<previous line indents here> 
{{ my_macro(arg1,
arg3) }} 

Problem 2: CSS indentation

I have the following style element:

<div parent>
  .indent-should-be-here {}

but in reality I am seeing:

<div parent>
.indent-on-the-left-most-why {}

I currently have Vim-Jinja2-Syntax installed. But it only calls the html indent. See .vim/bundle/Vim-Jinja-Syntax/indent/jinja.vim

" Vim indent file
" Language: Jinja HTML template
" Maintainer:   Evan Hammer <evan@evanhammer.com>
" Last Change:  2013 Jan 26

" Only load this indent file when no other was loaded.
if exists("b:did_indent")

" Use HTML formatting rules.
runtime! indent/html.vim

Does anyone have a recommendation for me?

  • turns out there's html5 plugin – Tinker Mar 11 '17 at 1:44

Try using == to auto-indent one line.

Use =G when you're at the top of page, to auto-indent the whole file

| improve this answer | |
  • Not what the OP asked. He obviously knows how to make Vim indent, as he provides samples of the result of such an operation; he is asking how to make Vim indent certain files correctly. – Amadan Mar 16 '17 at 4:56

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.