I want to add to the way html is indented in vim. I'm doing django development and I would like to indent whenever a django template tag is used. Currently, using filetype indent, it does not indent after the template tags. So currently my code looks like this:
{% do_something %}
<div>
<p>Hello</p>
</div>
{% end %}
And I'd like for it to recognize the {% %} as a tag and indent like so:
{% do_something %}
<div>
<p>Hello</p>
</div>
{% end %}
Is there a filetype plugin for this or a way I can add {% %} to the list of things that should be indented after?
Fix indentation in the whole fileStart in the top of a file (to get there, press gg anywhere in the file.). Then press =G , and Vim will fix the indentation in the whole file. If you don't start in the beginning of the file, it will fix indentation from current line to the bottom of file.
Within Vim, type a colon and then "set tabstop=4" which will set the tabs to display as four spaces. Hit colon again and type "set expandtab" which will insert spaces for tabs.
Globally Disable Auto-Indentation by Disabling the Filevim files (eg. sh. vim ) who set indentexpr option (eg to GetShIndent() ).
When you have filetype indent on
for an html file it will use the indenting rules found in the ../vim/vim73/indent subdirectory in file html.vim.
The braces you want to use as signaling indent of next line are, I'm sure, not treated in html.vim because they're not part of html. You can alter the rules in html.vim to get it done the way you want.
See :h indent-expr
for a bit of info and you will also want to look at other files in the /indent directory to see how it works.
There is an alternate html.vim you can get at vim website, maybe it is better than html.vim that ships with Vim: http://www.vim.org/scripts/script.php?script_id=2075
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With