I have a style element in an HTML file. When I type, NeoVim continuously indents each successive line:
In my Vim, it works correctly:
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 community
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.
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.
indent/html.vim from the current Vim upstream to your vimfiles:
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?