Loading ...
Sorry, an error occurred while loading the content.

Re: Formatting bash scripts

Expand Messages
  • John Aldridge
    ... I ve mostly been using gVim 6.2 in Windows, and I don t remember trying this on a Linux or Cygwin version of Vim. If equalprg is left empty, then Vim does
    Message 1 of 10 , Nov 5, 2003
    • 0 Attachment
      At 23:20 11-05-2003, Russell Shaw wrote:

      >John Aldridge wrote:
      >>At 20:49 11-05-2003, Russell Shaw wrote:
      >>
      >>>Gary Johnson wrote:
      >>>
      >>>>On 2003-11-05, Russell Shaw <rjshaw@...> wrote:
      >>>>
      >>>>>Hi,
      >>>>>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...
      >>>
      >>>
      >>>Hi,
      >>>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:
      >> 1G=G
      >
      >Equalprg works on C, but is there something for bash scripts?

      I've mostly been using gVim 6.2 in Windows, and I don't remember
      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.
    Your message has been successfully submitted and would be delivered to recipients shortly.