I have bash script which Vim detects as a sh according to :set filetype?. In addition, Vim-script for auto-indention support for shell-scripts(/usr/share/vim/vim74/indent/sh.vim) is also present. However, for example following while loop:
while read -ra line"$line_id"_fields; do
line_id=$((line_id+1))
done < "$1"
..is auto intended(gg=G) to this:
while read -ra line"$line_id"_fields; do
line_id=$((line_id+1))
done < "$1"
What might cause this?
:filetype plugin indent onin your .vimrc. Then in your shell script check that:verbose set indentexpr?returns something like this:indentexpr=GetShIndent() Zuletzt gesetzt von /usr/share/vim/vim74/indent/sh.vim– Christian Brabandt Sep 06 '16 at 21:47filetype indent onwas missing. Once I added this to my.vimrcfile, auto-indention feature works fine. I actually tried that before, but for some reasonfiletype indent onworks only if I set this in my.vimrcfile. If I have the bash script open and typefiletype indent on(and I can confirm that it is on withfiletypecommand), then auto-indent does not work. – Martin Sep 12 '16 at 06:46