If I indent the following script with gg=G
:
#!/usr/bin/env bash
while true; do
case "${1}" in
-h) usage; exit 0;;
-b) branch="${2}"; shift 2;;
-t) build="${2}"; shift 2;;
-w) write=true; shift 1;;
--) shift; break;;
esac
done
it gets differently indented on two different machines. On machine 1, the indentation is as above, on machine 2, all the different cases (starting from -b
) gets indented to the left. Both machines have exactly the same .vimrc
, where I use aindent
only. On machine 1, vim is version 8.0, on machine 2, it's 7.4. Surely the version should not have such an effect? What else could lead to a different indentation?
Here are a few settings that I use on machine 1:
filetype detection:ON plugin:ON indent:ON
softtabstop=0
tabstop=4
Last set from ~/.vimrc
shiftwidth=4
Last set from ~/.vimrc
nocindent
indentexpr=
autoindent
Last set from ~/.vimrc
nosmartindent
And indeed there is one difference on machine 2:
indentexpr=GetShIndent()
Last set from /usr/share/vim/vim74/indent/sh.vim
Removing it does not improve the situation, though. So after all, it might be due to a difference in the version of vim. Is there a good setting of indenting that works for both versions?
:filetype
. Also, Vim 8 comes with better indent script for shell scripts. Also interesting to know::verbose set sts? ts? sw? cindent? indentexpr? autoindent? smartindent?
– Christian Brabandt Aug 23 '17 at 17:17:filetype
for both systems. I suppose, that one includesindent: ON
while the other does not. So that:filetype
correctly should fix it for you. BTW, if the indent script does not work correctly for the case statement above, you might want to create a new issue on github.com/chrisbra/vim-sh-indent – Christian Brabandt Aug 24 '17 at 8:20