Reputation: 5569
When I edit HTML, I sometimes like to line-up attribute declarations like this:
<li class="dropdown"
ui-route="..."
ng-class="{active: $uiRoute}">
</li>
However, when I'm at the end of line 2 of my example and I enter a newline, vim seems to correct the indentation of line 2 to that of line 1. Here's a GIF of it happening:
I have autoindent
on but disabling it doesn't seem to help.
Can I tell vim to stop doing that?
Upvotes: 2
Views: 58
Reputation: 195289
This is because you have set filetype indent on
and the indent file: xml.vim
was loaded.
If you rename the file to something like foo.vim.txt
and vim foo.vim.txt
, the indent would not be automatically adjusted when you pressed Enter.
More detailed info:
In you $VIMRUNTIME/indent/xml.vim
, you can find:
setlocal indentkeys=o,O,*<Return>,<>>,<<>,/,{,}
that is, when you pressed <Return>
in your xml
file, the indent adjustment was triggered. read :h indentkeys
for details.
If you don't want to let vim re-indent your line when you press <enter>
, you can try setlocal indentkeys -=*<Return>
. If you want it only to happen on certain filetype, i.e. xml
, you can create autocommand.
Hope it helps.
html
file, it is the same. You can check $VIMRUNTIME/indent/html.vim
, you will see <Enter>
is in the list too.Upvotes: 2