Change vim indent format

I want to add that html is indented in vim. I am developing django and I would like to back out whenever the django template tag is used. Currently, using indentation of type filetype, it does not indent after template tags. So, currently my code looks like this:

{% do_something %} <div> <p>Hello</p> </div> {% end %} 

And I would like it to recognize {%%} as a tag and indent like this:

 {% do_something %} <div> <p>Hello</p> </div> {% end %} 

Is there a filetype plugin for this or a way that I can add {%%} to the list of things that should be indented after?

+6
source share
2 answers

When you have a filetype indent on for an html file, it will use the indentation rules found in the .. / vim / vim 73 / indent subdirectory in the html.vim file.

The brackets you want to use as the indent of the next line, I'm sure, are not processed in html.vim because they are not part of html. You can change the rules in html.vim to make it the way you want.

See :h indent-expr for a bit of information, and you'll also want to look at other files in the / indent directory to find out how this works.

There is an alternative html.vim that you can get on the vim website, perhaps better than the html.vim that comes with Vim: http://www.vim.org/scripts/script.php?script_id= 2075

+1
source

While waiting for the migration request for django.vim, enable the django-custom vim alternative from Steve Losch. This works, for the most part, better than the default.

0
source

Source: https://habr.com/ru/post/902866/


All Articles