Since my last system update (I think), I have noticed this very annoying behavior.
# vim foo.html
# I go to insert mode, I type (no whitespace except newlines)
<html>
<head>
<script>
- That's four tabs in front of that
<script>
, instead of two. - The two extra tabs are added right when I type that final closing
>
. - With
set softtabstop=2 shiftwidth=2 expandtab
it's the same, but spaces. - The other tags don't matter, the
<script>
can be anywhere like "^\s+<script>
". - It doesn't happen when
<script>
has any other attribute (like asrc
,type
orfoo="bar"
)... could this be a bug? - UPDATE: when I type a closing
</script>
in the same line the extra indentation is removed with, again, the final>
.
# .vimrc
filetype plugin indent on
# vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 17 2020 21:54:53)
Included patches: 1-1704
Compiled by Arch Linux
…
<esc>==
actually fixes it? the JS indenting inside<script>
is generally not too great – D. Ben Knoble♦ Oct 27 '20 at 13:19<script>
will actually be on the same indent as<head>
, which isn't really correct either. I don't really know what a fix is, but you can put a copy ofindent/html.vim
in~/.vim/indent/html.vim
without this change to get the old behaviour back. – Martin Tournoij Oct 27 '20 at 22:18