Skip to content
Advertisement

auto-formating tool for django html template files

Is there a *nix tool (or vim plug-in) that would allow me to automatically format django html template files?

Hitting the space bar hundreds of time does not sound like a good use of my time but then neither does leaving some weird formatting that is hard to read.

Advertisement

Answer

  1. Install vim-jinja2-syntax plugin by putting Glench/Vim-Jinja2-Syntax when installing it with plugin manager (vim-plug, Vundle etc.)
  2. Put autocmd FileType html setlocal expandtab shiftwidth=2 tabstop=2 in the vim config file, which is usually at ~/.vimrc.
  3. run gg=G in django html file(aka jinja template)
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement