When editing PHP code (I'm not sure if it's specific to that language) and I create a new line in the middle of comma-separated lists that span multiple lines, the indent rules always unindent the line I'm leaving. Here's a video of it. This happens in arrays, function argument lists, etc.
Is there anything I can do to stop this from happening, or any quicker methods of fixing the error than moving up, re-indenting it, moving down, re-indenting (since it gets cleared when you leave the line), and continuing?
.vimrc
Try :set indentexpr=""
and see if that helps. See :help filetype-indent-off
for the section that deals with filetype plugins (which is probably where this indentexpr is coming from).
Your indenting is controlled by the PHP indent script ("filetype indent on" in your .vimrc). I use these options for my PHP indenting, which you put in ~/.vim/after/ftplugin
:
setlocal autoindent
setlocal cindent
setlocal cinwords=if,else,elseif,do,while,foreach,for,case,default,function,class,interface,abstract,private,public,protected,final
setlocal cinkeys=0{,0},0),!^F,o,O,e
setlocal nosmartindent " don't use smart indent option
There's more on this topic on the vim wiki page for source indenting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With