I have a style element in an HTML file. When I type, NeoVim continuously indents each successive line:
In my Vim, it works correctly:
My vimrc.
I would be grateful for any suggestion. Thanks!
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityI have a style element in an HTML file. When I type, NeoVim continuously indents each successive line:
In my Vim, it works correctly:
My vimrc.
I would be grateful for any suggestion. Thanks!
This particular issue seems to have come up more than once:
Unfortunately the replies and answers mostly consist of non-solutions (suggesting to turn off filetype
entirely) or workarounds (set indentkeys+=;
). After a lot of digging, I gained more useful knowledge.
The current indent/html.vim
that ships with the (Neo)Vim runtime is a fork of Andy Wokula's indent file. This fork was originally created and is currently maintained by Bram himself in 2014. It is this overhaul where this CSS-indentation bug was first introduced; Andy's original HTML indent file did not have this indentation issue. Ever since then, it has remained.
A very recent upstream commit (22 days ago from the time of writing) included an update to indent/html.vim
that fixes the CSS-indentation. Adding this upstream version to ~/<vimfiles>/indent
and reproducing the example in your question gives the desired behavior.
Add the indent/html.vim
from the current Vim upstream to your vimfiles:
~/.config/nvim/indent
~/.vim/indent
And of course, make sure that filetype plugin indent on
exists somewhere in your configuration.
* This question predates the overhaul fork in 2014, but presents the same symptoms. Perhaps the 2007 version happened to have the same issue?
filetype plugin indent on
setup. What does:set inde? ai? si?
give you? Do you possibly have a plugin installed with its own indent file for CSS? You can check with::filter /indent/ scriptnames
. – ZeroKnight Sep 17 '18 at 21:30nvim -u NONE -c ':filetype plugin indent on | :e test.html'
.HtmlIndent()
is definitely the cause. – ZeroKnight Sep 19 '18 at 20:04