Re: Formatting bash scripts
- At 23:20 11-05-2003, Russell Shaw wrote:
>John Aldridge wrote:I've mostly been using gVim 6.2 in Windows, and I don't remember
>>At 20:49 11-05-2003, Russell Shaw wrote:
>>>Gary Johnson wrote:
>>>>On 2003-11-05, Russell Shaw <rjshaw@...> wrote:
>>>>>Is there a tool for setting the right indentation
>>>>>formatting for bash scripts?
>>>>You mean something other than $VIMRUNTIME/indent/sh.vim? It seems
>>>>to do pretty well except for case labels. That is, it formats a
>>>>case command as...
>>>I meant a beautifier thing to neaten up a large script with
>>>inconsistant indents. If you can get the indents right, then
>>>you can set folds using the indents which makes debugging large
>>>shell scripts much easier.
>>>If you want to set the indents while entering bash code, then
>>>see 30.3-30.4 of help.
>>Is the '=' not working for you (with the indent/sh.vim)? As in:
>Equalprg works on C, but is there something for bash scripts?
trying this on a Linux or Cygwin version of Vim. If equalprg is left
empty, then Vim does what it can without an external program. That
means that Vim uses the indent/sh.vim or whatever indent file
applies. As mentioned earlier, bash case statements don't come out
all the nicely, but the rest seems to work quite well. I also get a
lot of use out of this on borrowed HTML files which are often badly
indented. The advantage of the '=' key is that you get to set your
shiftwidth and expandtab as you prefer. Of course, you can also
alter the indent file to taste.