2

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,
            arg2,
            arg3) }} 

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

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

Problem 2: CSS indentation

I have the following style element:

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

but in reality I am seeing:

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

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 <[email protected]>
" Last Change:  2013 Jan 26

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

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

Does anyone have a recommendation for me?

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

1 Answer 1

-2

Try using == to auto-indent one line.

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

1
  • 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, 2017 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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