Controlling shell indent

24 views
Skip to first unread message

James Michael Fultz

unread,
Nov 9, 2009, 5:25:46 AM11/9/09
to Vim Use
How do I control the indentation in shell scripts when using the
filetype indent plugin?

I have consulted Vim's documentation and found the section on
ft-sh-indent to be confusing. The documenation found on the Web is the
same as what I have locally.

<http://vimdoc.sourceforge.net/htmldoc/indent.html#ft-sh-indent>

I have tried setting the documented values in
'~/.vim/after/indent/sh.vim' as well as setting values manually with
a shell file loaded. Both result in undefined variable error when
trying to set dictionary keys.

I have looked in '/usr/share/vim/vim72/indent/sh.vim' and have not found
any references to the variables documented.

I am running Vim 7.2 on Ubuntu 9.04 and have filetype detection, plugin,
and indent enabled.

Gary Johnson

unread,
Nov 9, 2009, 12:42:10 PM11/9/09
to vim...@googlegroups.com

What aspect of the indentation are you trying to control? What
variables are you trying to set, how exactly are you trying to set
them, and what exactly happens when you try?

Regards,
Gary


James Michael Fultz

unread,
Nov 9, 2009, 6:33:15 PM11/9/09
to vim...@googlegroups.com
* Gary Johnson <gary...@spocom.com> [2009-11-09 09:42 -0800]:

>
> On 2009-11-09, James Michael Fultz wrote:
> > How do I control the indentation in shell scripts when using the
> > filetype indent plugin?
> >
> > I have consulted Vim's documentation and found the section on
> > ft-sh-indent to be confusing. The documenation found on the Web is the
> > same as what I have locally.
> >
> > <http://vimdoc.sourceforge.net/htmldoc/indent.html#ft-sh-indent>

Have a look at the documentation. There seems to be conflicting or at
least confusing information whether it is b:sh_indent_defaults or
b:sh_indent_options.

> What aspect of the indentation are you trying to control? What
> variables are you trying to set, how exactly are you trying to set
> them, and what exactly happens when you try?

I want to change the indent of case statements. Trying to set any of
the documented dictionary keys results in the same error message. For
example:

:let b:sh_indent_options['case-labels'] = 0

Results in:

E121: Undefined variable: b:sh_indent_options

Anyway, this may be a wild goose chase since sh_indent_options nor
sh_indent_defaults is referenced in none of the installed plugins. As
a comparison, look at the documentaton for Python indent.

<http://vimdoc.sourceforge.net/htmldoc/indent.html#ft-python-indent>

The documented variables can be found in the python.vim indent plugin.

Gary Johnson

unread,
Nov 9, 2009, 12:01:42 PM11/9/09
to Vim Use
On 2009-11-09, James Michael Fultz wrote:

What aspect of the indentation are you trying to control? What


variables are you trying to set, how exactly are you trying to set
them, and what exactly happens when you try?

Regards,
Gary


Gary Johnson

unread,
Nov 9, 2009, 8:13:31 PM11/9/09
to vim...@googlegroups.com

OK, I see the problem now. The most recent version of vim I have is
7.2.264 and it still came packaged (for Cygwin) with indent/sh.vim
revision 2006-04-19, which uses neither b:sh_indent_defaults nor
b:sh_indent_options. The vim-7.2.184 for Windows that I got from
the Cream project also has the old indent/sh.vim. Yet, ":help
ft-sh-indent" for all the versions of vim I have describe
b:sh_indent_options.

The problem is that the latest official release of vim is 7.2 with
no patches. It is up to anyone building a patched version to
download and apply the patches themselves. The patches, however, do
not include any updates to the runtime files, so one has to also
download and install the latest runtime files. That apparently
wasn't done by the folks distributing the vim packages that you and
I have. That, or the new indent/sh.vim didn't make it into the
runtime repository.

I've been lax in keeping the vim installations I build myself up to
date, so I don't know whether the runtime repository currently has
the new indent/sh.vim or not.

There is definitely an error in the current help documentation as
well, but I don't know whether the correct name for the dictionary
is sh_indent_defaults or sh_indent_options.

To find out how to download the latest runtime files, see

http://vim.sourceforge.net/runtime.php

Regards,
Gary


James Michael Fultz

unread,
Nov 9, 2009, 9:11:56 PM11/9/09
to vim...@googlegroups.com
* Gary Johnson <gary...@spocom.com> [2009-11-09 17:13 -0800]:

> On 2009-11-09, James Michael Fultz wrote:
[changing indent of case statements in shell files and incongruity of
documented options for 'indent/sh.vim' plugin]

>
> OK, I see the problem now. The most recent version of vim I have is
> 7.2.264 and it still came packaged (for Cygwin) with indent/sh.vim
> revision 2006-04-19, which uses neither b:sh_indent_defaults nor
> b:sh_indent_options. The vim-7.2.184 for Windows that I got from
> the Cream project also has the old indent/sh.vim. Yet, ":help
> ft-sh-indent" for all the versions of vim I have describe
> b:sh_indent_options.

Vim 7.2.79 here and same revision of 'indent/sh.vim'.

> The problem is that the latest official release of vim is 7.2 with
> no patches. It is up to anyone building a patched version to
> download and apply the patches themselves. The patches, however, do
> not include any updates to the runtime files, so one has to also
> download and install the latest runtime files. That apparently
> wasn't done by the folks distributing the vim packages that you and
> I have. That, or the new indent/sh.vim didn't make it into the
> runtime repository.

Would this be a packaging bug?

> I've been lax in keeping the vim installations I build myself up to
> date, so I don't know whether the runtime repository currently has
> the new indent/sh.vim or not.

OK, seems the new 'indent/sh.vim' isn't in the runtime repository. It
is the same revision I already had installed -- 2006-04-19.

> There is definitely an error in the current help documentation as
> well, but I don't know whether the correct name for the dictionary
> is sh_indent_defaults or sh_indent_options.

Should I file a bug report on it?

> To find out how to download the latest runtime files, see
>
> http://vim.sourceforge.net/runtime.php

Thanks for your help.

Gary Johnson

unread,
Nov 9, 2009, 10:56:45 PM11/9/09
to vim...@googlegroups.com
On 2009-11-09, James Michael Fultz wrote:
> * Gary Johnson <gary...@spocom.com> [2009-11-09 17:13 -0800]:

> > The problem is that the latest official release of vim is 7.2 with


> > no patches. It is up to anyone building a patched version to
> > download and apply the patches themselves. The patches, however, do
> > not include any updates to the runtime files, so one has to also
> > download and install the latest runtime files. That apparently
> > wasn't done by the folks distributing the vim packages that you and
> > I have. That, or the new indent/sh.vim didn't make it into the
> > runtime repository.
>
> Would this be a packaging bug?

It's a bug somewhere. If, as you say below, the runtime repository
doesn't contain the version of a plugin that matches the latest
documentation, then there will be an error in the package but it
won't be the fault of the packager.

> > I've been lax in keeping the vim installations I build myself up to
> > date, so I don't know whether the runtime repository currently has
> > the new indent/sh.vim or not.
>
> OK, seems the new 'indent/sh.vim' isn't in the runtime repository. It
> is the same revision I already had installed -- 2006-04-19.
>
> > There is definitely an error in the current help documentation as
> > well, but I don't know whether the correct name for the dictionary
> > is sh_indent_defaults or sh_indent_options.
>
> Should I file a bug report on it?

I think you should file reports on both bugs.

> Thanks for your help.

You're welcome.

Regards,
Gary


Matt Wozniski

unread,
Nov 10, 2009, 6:49:07 PM11/10/09
to vim...@googlegroups.com
On Mon, Nov 9, 2009 at 10:56 PM, Gary Johnson wrote:
>
> On 2009-11-09, James Michael Fultz wrote:
>> * Gary Johnson <gary...@spocom.com> [2009-11-09 17:13 -0800]:
>
>> > The problem is that the latest official release of vim is 7.2 with
>> > no patches.  It is up to anyone building a patched version to
>> > download and apply the patches themselves.  The patches, however, do
>> > not include any updates to the runtime files, so one has to also
>> > download and install the latest runtime files.  That apparently
>> > wasn't done by the folks distributing the vim packages that you and
>> > I have.  That, or the new indent/sh.vim didn't make it into the
>> > runtime repository.
>>
>> Would this be a packaging bug?
>
> It's a bug somewhere.  If, as you say below, the runtime repository
> doesn't contain the version of a plugin that matches the latest
> documentation, then there will be an error in the package but it
> won't be the fault of the packager.

It's an upstream problem, for sure.

ftp://ftp.vim.org/ftp/pub/vim/runtime/doc/indent.txt mentions
sh_indent_options and sh_indent defaults

ftp://ftp.vim.org/ftp/pub/vim/runtime/indent/sh.vim uses neither.

Since those are the latest runtime files from FTP in both cases, the
docs definitely don't match up with the indent script.

~Matt

Tony Mechelynck

unread,
Dec 4, 2009, 1:58:36 AM12/4/09
to vim...@googlegroups.com, Matt Wozniski
I notice that the current indent/sh.vim (which uses that Dictionary) is
dated 2009-11-12, i.e., three days after you posted this. So either the
change was "in the queue for the next update" when you posted this, or
you triggered the fix.

Best regards,
Tony.
--
Don't abandon hope: your Tom Mix decoder ring arrives tomorrow.

James Michael Fultz

unread,
Dec 4, 2009, 2:23:43 AM12/4/09
to vim...@googlegroups.com
* Tony Mechelynck <antoine.m...@gmail.com> [2009-12-04 07:58 +0100]:
[ indent/sh.vim help mismatch ]
>
> I notice that the current indent/sh.vim (which uses that Dictionary) is
> dated 2009-11-12, i.e., three days after you posted this. So either the
> change was "in the queue for the next update" when you posted this, or
> you triggered the fix.

Yeah, I filed a bug report on it, and Bram and Nikolai got right to work
on it.
Reply all
Reply to author
Forward
0 new messages