On 2012-01-11, Linda W wrote:
>
> This may have something to do with my settings, or is some endemic problem in
> language based indenting.
>
> For my indent settings, I have 'si' set, but not 'ai',
>
>
> However, in 2 different languages, perl and javascript,
>
> having a backslash in a line will automatically cause indenting on the next
> line to be incorrect.
>
>
> example1: (javascript) with the '\\' audo indent does:
> {
> {
> var halfWidthTLDPattern = '(?:'+TLD.join('|')+')\\b';
> var TLDPattern =
>
> ---
> (indent set to '1' in this script), so it places 2nd line var 2 levels
> before where it should be. if I
> change the "\\" to "||" (not practical in real life)...
> var halfWidthTLDPattern = '(?:'+TLD.join('|')+')||b';
> var TLDPattern =
>
> Same thing happens in perl (which is where I noticed it first).
> I thought it might be perl-syntax specific, but in editing a javascript
> file today, (someone else's, actually), I noticed the same behavior.
>
> So could there be something peculiar in my settings that would cause this?
>
> Why "\"?
>
> "It's pretty consistent" -- *strike that*.. (just testing a few cases)...
> going to my perl code... so .. here's a perl example:
>
> sub one {
> my $x = sub2 () {
> return \$_[0];
> } ## wrong haven't finished sub2 yet
> my $val;
> my $aval=\$val;
> my $wrong_indent; # this line was 'de-indented' due to the BckSl.
> -or-
> sub one {
> my $x = sub2 () {
> return \\;
> } #doubly unhappy!
>
>
> I tried it in 'vim' as well... same thing. so not 'g' related, and as
> it happens on win & unix, not win related.
>
> My 'settings' when I type 'set' (i.e. the non defaults -- had to copy
> them from 'vim', since 'gvim' won't let you copy it's output of settings.
> (a feature?) (when editing the perl file)
[...]
A way to determine whether the behavior is due to your settings is
this:
$ vim -N -u NONE --cmd ":filetype indent on" foo.pl
With that, I see the same odd indenting behavior that you describe,
so it's not you.
Also, 'si' has no effect if 'indentexpr' is set.
I found the problem. There is a bug in $VIMRUNTIME/indent/perl.vim.
The author tried to match braces with this:
[(){}\[\]]
The trouble is, \[ is not an escaped [ because there is no need to
escape a [ within []. \[ is instead just the two characters \ and
[, so that expression was matching your backslashes. The solution
is to remove the backslashes preceding each [.
The bug occurs three times in that file: at lines 127, 144 and 156.
Fixing all those seems to fix the indenting problem.
I have cc'd the author.
Thanks for the clear description of the problem.
Regards,
Gary
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php