When vim edits an html file, the indentation of the previous line changes after the line breaks.

  question, vim

For example, if you look at this code, notice that the < li > tag is preceded by three spaces, and my vim settings are as follows

set tapstop=4
set softtabstop=4
set shiftwidth=4

The reason why the < li > tag has three spaces before it is because I changed someone else’s code, and I don’t want to mess up the original indentation.

<ul>
   <li>**光标所在处,在此处回车**
   </li>
</ul>

Press enter at the position marked above, < li > the three spaces in front of this label will be replaced by tab, as shown in the figure

qian.png

hou.png

How can I solve the problem of changing the indent of the previous line?

“Spaces replace tab, this is the point
set expandtab

“Indent 3 characters
set shiftwidth=3 softtabstop=3

“The following is about the control of automatic indentation. If you don’t like automatic indentation, you can turn it off.
“Auto indent
set ai

” Smart indet
set si

” C-style indeting
set cindent

You can also use modeline without modifying your vim configuration. Please refer to:http://vim.wikia.com/wiki/Modeline_ma …