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 on
in 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 6 '16 at 21:47filetype indent on
was missing. Once I added this to my.vimrc
file, auto-indention feature works fine. I actually tried that before, but for some reasonfiletype indent on
works only if I set this in my.vimrc
file. If I have the bash script open and typefiletype indent on
(and I can confirm that it is on withfiletype
command), then auto-indent does not work. – Martin Sep 12 '16 at 6:46