search

Home  >  Q&A  >  body text

gvim - The problem of the indentation of the previous line changing after a new line when vim edits the html file

For example, take this code. Note that there are three spaces in front of the <li> tag, and my vim settings are as follows

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

The reason why there are three spaces in front of the <li> tag is because I am changing someone else’s code and I don’t want to mess up the original indentation

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

Enter at the marked position above, <li>the three spaces in front of this label will be replaced with tabs, as shown in the figure

How to solve this problem of changing the indentation of the previous line by changing the line?

世界只因有你世界只因有你2774 days ago783

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-05-16 16:44:52

    " Use spaces instead of tabs, this is the key 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 index
    set si

    " C-style indeting
    set cindent

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

    reply
    0
  • Cancelreply